This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Missing warning


Using recent versions of gcc, and the options -O -Wall the test case
below should provove a warning from the compiler of an unitialised
variable, 'errcode'.

Gcc releases:

  * gcc version 4.7.1 (Debian 4.7.1-2) 
  * gcc version 4.7.0 20120225 (experimental) (FreeBSD Ports Collection) 
  * gcc version 4.6.4 20120309 (prerelease) (FreeBSD Ports Collection) 

(OK, I realise none is an official release, but I feel confident enough that
this bug is in the official releases too.)

Command:

  * gcc -O -Wall foo.c

Expected behaviour:

  A warning diagnostic message.

Obsorved behaviour:

  No diagnostic output.


Test case foo.c:

    int
    variable_errcode_is_uninitialised (const char *s)
    {
      int errcode;

      for (;;)
        {
          unsigned c = *s++;
          if (c == 0)
            break;			/* errcode uninitialised on this path */

          if (c < '0')
            {
              errcode = -1;
              break;		/* errcode initialised on this path */
            }
        }

      return errcode;
    }

-- 
TorbjÃrn


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]