I have the following defined in the header file:
some function ...
if (table2[i] != ""){
new_table2[hash2(table2[i])] = table2[i];
table2[i] = "";
}
// std::cout << " first i : " << i << "\n";
}
for (int i=0; i < 150; ++i){
if (new_table1[i] != "" && !try_insert(new_table1[i])){
std::cout << " bad rehash : " << i << " " << new_table1[i] << "\n";
rehash();
}
}
Makefile looks like this:
CC=g++
CFLAGS=-Wall -Wextra -O3.
DEPS = somehash.h hashfunctions.h
OBJ = main.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
main: $(OBJ)
g++ -o $@ $^ $(CFLAGS)
.PHONY: clean
clean:
rm -f *.o main
After I do make clean, make, and ./main, "first i" is still printed even though it is commented out. When I comment out " bad rehash ", then both of them are not printed. It seems the compiler did some auto optimization that causes this to be cached? How can I fix it?
Aucun commentaire:
Enregistrer un commentaire