Reputation:
I'm using 4.1.2. Does anyone have any ideas of the best places in my code to look? Experience with common causes? There are some ugly pointer casts (ie, d = (double) (* (float *) p), where p is pointer-to-int) that I'm working on eliminating, but no luck yet.
For what it's worth, -O0 is giving the correct answer. Thanks for any help.
Upvotes: 4
Views: 574
Reputation:
Thanks everyone, -fno-strict-aliasing (suggested by several) solved my problem. Thanks for all your help.
Lesson learned: Always compile with warning flags.
Upvotes: 3
Reputation: 15133
I'd check for strict aliasing issues, as demonstrated here: http://www.cellperformance.com/mike_acton/2006/06/understanding_strict_aliasing.html
Without knowing exactly what your code does, the mention of "ugly pointer casts" make me suspect aliasing problems.
It would be helpful for you, and make it easier for us to answer, if you provided some code that demonstrated the issue.
Upvotes: 7