Is this an useful optimization ??
Posted Apr 19, 2008 19:19 UTC (Sat) by giraffedata
In reply to: Is this an useful optimization ??
Parent article: GCC and pointer overflows
I think you are missing the point that this code is often both valid and intentional.
No, I did get that point, and it's orthogonal to my point, which was that the compiler is not optimizing away my code, so need not warn me that it has optimized away my code.
The first point I made in the same post is that I prefer no warning unless there is a way for me to disable it, which is directly derived from your point that the code is often both valid and intentional.
However: I can see your real point is that the code is not only intentional, but is intended to mean something different from what the standard says it means. That, I suppose, means the warning says, "you wrote something that often is intended to say something other than what it really says." I agree that's a valid warning. It's like the
warning for "if (a = b)". It's still not a case of the user's code being "optimized away."
After all this is C, not Lisp, so a programmer is supposed to be aware that integer types wrap around, etc.
While quite low level, C is not so low level that integer types wrap around. You're just talking about particular implementations of C. The warning we're talking about warns the programmer that something didn't wrap around as expected.
to post comments)