Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Agree on the alarm bells with the pointer arithmetic.

Disagree that gcc is doing the right thing here. The clang behavior (different comment in this thread) is much more sane: if the pointers happen to be the same, they compare as equal. If the pointers happen to not be the same, they compare as not equal.



Except clang's behaviour changes depending on the optimisation level. If you use -O1, then you get a different result.


Yes, because the pointers are different at -O.

As there are no guarantees as to the relative placement of auto/stack variables relative to each other, that is perfectly fine.


If the behaviour differs at optimisation levels, would that not suggest that it is not a sane behaviour?


Not in this case, no, not at all.

Finding a different layout for auto variable in the stack frame at different optimization levels is perfectly fine.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: