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.
- 3could you provide a minimum (non) working example ?Gyom– Gyom2009-07-02 02:44:52 +00:00Commented Jul 2, 2009 at 2:44
- Are you compiling with -Wall and -Wextra?Adam Rosenfield– Adam Rosenfield2009-07-02 02:50:07 +00:00Commented Jul 2, 2009 at 2:50
- Sorry, I'm working on it. Heavy going.Alex– Alex2009-07-02 02:51:54 +00:00Commented Jul 2, 2009 at 2:51
- delta.tigris.org is an excellent tool for automated minimization of a test case.ephemient– ephemient2009-07-02 18:27:53 +00:00Commented Jul 2, 2009 at 18:27
- The other thing that would lead to slightly different results with optimization is that the x86 FPU has more precision than specified, so unoptimized code that forces values to be written into the stack frame between operations will truncate the lower bits.Simon Richter– Simon Richter2011-05-11 10:45:34 +00:00Commented May 11, 2011 at 10:45
Add a comment |
2 Answers
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.
2 Comments
an0nym0usc0ward
The post stackoverflow.com/questions/83962/… shows a similar problen
Thanks everyone, -fno-strict-aliasing (suggested by several) solved my problem. Thanks for all your help.
Lesson learned: Always compile with warning flags.
1 Comment
ephemient
Stack Overflow is not a forum. Answers may be reordered for many reasons, such as votes and edits, and thus should not be used to reply to other answers. Please leave comments or edit the question instead. Also, if your issue has been resolved due to an answer, please mark it as accepted (click the green check mark under the vote counter). Don't forget to vote up helpful responses!