Re: [suse-programming-e] SuSE-9.0 gcc-3.3.1 optimization turns off important warning
Marcus Meissner <meissner@suse.de> writes:
On Wed, Dec 31, 2003 at 09:22:36AM -0500, Mark Gray wrote: [snip]
It is the toupper that turns it off then:
markgray@soyo:/usr/src/packages/BUILD/bug> cat xx.c #include <ctype.h>
void strupr_OLD (char *s) { while (*s) { *s++ = toupper(*s); } }
markgray@soyo:/usr/src/packages/BUILD/bug> gcc -O2 -Wall -c xx.c markgray@soyo:/usr/src/packages/BUILD/bug>
(This is also 9.0 btw)
Hmm. Probably because *s++ = toupper(*s); is translated by a macro to:
*s++ = (__extension__ ({ int __res; if (sizeof (*s) > 1) { if (__builtin_constant_p (*s)) { int __c = (*s); __res = __c < -128 || __c > 255 ? __c : (*__ctype_toupper_loc ())[__c]; } else __res = toupper (*s); } else __res = (*__ctype_toupper_loc ())[(int) (*s)]; __res; }));
Might be to hard for the compiler to spot the problem.
As an assembly language programmer, I find it highly amusing that such a macro generates so few machine instructions :-)
participants (1)
-
Mark Gray