[PATCH] Quieten arch/powerpc in a allmodconfig build.

Segher Boessenkool segher at kernel.crashing.org
Sat Apr 11 06:28:28 EST 2009


>>> The problem is that GCC does not give an error (only a warning)  
>>> even for
>>> things like this where it should be trivial to detect that the  
>>> usage *is*
>>> uninitialized, not just might be:
>>>
>>> int foo(void)
>>> {
>>>    int a;
>>>
>>>    return a;
>>> }
>> The compiler must not reject this code, because the undefined  
>> behavior
>> only occurs if executed.  There is no constraint violated.
>
> Fine (though GCC could have something similar to -Werror but more  
> limited in scope to the really serious stuff that *should* be  
> illegal even if it isn't), but it should at least be a separate  
> warning class.
>
> My point was to counter Segher's assertion that the compiler  
> currently gives an error on the obvious stuff.

I never said that, or didn't intend to anyway; what I was trying to say
is that the compiler makes a difference between cases where it knows
something is uninitialized vs. cases where it cannot prove either way:

$ cat mm.c
int bork(void)
{
         int a;

         return a;
}

int main(void)
{
         return bork();
}

$ powerpc-linux-gcc -Wall -W -Os -c mm.c
mm.c: In function 'bork':
mm.c:5: warning: 'a' is used uninitialized in this function

Note: _is_ used uninitialized, not "may be" like in cases where the  
compiler
isn't sure.

I don't know why this isn't an error; perhaps GCC does not assume main 
() to
always be executed.  I don't think it could prove much anything to be
executed in non-toy examples, anyway.


Segher




More information about the Linuxppc-dev mailing list