Uninitialized integers and warnings

Ian Lance Taylor iant@google.com
Wed Sep 4 14:06:00 GMT 2013


On Wed, Sep 4, 2013 at 6:40 AM, Kirill Tkhai <tkhai@yandex.ru> wrote:
>
> the following example compiles without warnings:
>
> $ cat a.c
> int func (int p)
> {
>         int x;
>         if (p != 0)
>                 x = 1;
>         return x;
> }
>
> $ gcc -c a.c -Wall
> (no messages)
>
> Is there no error? Why compiler doesn't print a error
> about uninitialized variable?
>
> I saw many pieces like this in GNU software. Does
> it mean that it is a de-facto standard and gcc won't warn
> about code like this in the future?

This question would be more appropriate on the mailing list
gcc-help@gcc.gnu.org.  The mailing list gcc@gcc.gnu.org is for
discussions about the development of GCC itself.  Please take any
followups to gcc-help.  Thanks.

That said, I think this case is a bug.  Please report it following the
instructions at http://gcc.gnu.org/bugs.  Thanks.

Ian



More information about the Gcc mailing list