Mailinglist Archive: opensuse-programming (58 mails)
| < Previous | Next > |
Re: [suse-programming-e] SuSE-9.0 gcc-3.3.1 optimization turns off important warning
- From: Mark Gray <markgray-temp-1072781312@xxxxxxxxxxxx>
- Date: 31 Dec 2003 09:22:36 -0500
- Message-id: <6sfzf15aoj.fsf@xxxxxxxxxxxx>
Marcus Meissner <meissner@xxxxxxx> writes:
>> But why is there no warning when optimization is turned on? (When the
>> warning is actually needed :-) This is my main point.
>
> It is there with -Wall on SuSE Linux 9.0:
>
> $ cat xx.c
> void f(char *s) {
> while (*s) {
> *s++ = *s | 0x20;
> }
> }
> $ gcc -O2 -Wall -c xx.c
> xx.c: In function `f':
> xx.c:3: Warnung: operation on `s' may be undefined
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)
>> But why is there no warning when optimization is turned on? (When the
>> warning is actually needed :-) This is my main point.
>
> It is there with -Wall on SuSE Linux 9.0:
>
> $ cat xx.c
> void f(char *s) {
> while (*s) {
> *s++ = *s | 0x20;
> }
> }
> $ gcc -O2 -Wall -c xx.c
> xx.c: In function `f':
> xx.c:3: Warnung: operation on `s' may be undefined
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)
| < Previous | Next > |