http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57407

            Bug ID: 57407
           Summary: Missing uninitialized warning following assert
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stuff0003 at pobox dot com

In certain circumstances following an assertion, there is no warning for an
uninitialised variable.
(keyword also: uninitialized)

$ cat nowarn.c
#include <stdio.h>
#include <assert.h>
int main(int ac,char**av){
  int e,f;
  f=1;assert(f);
  printf("%d\n",e);
  return 0;
}
$ gcc -c nowarn.c -Wall -O3
$
(no warning generated)

Note that without optimisation you get the expected result:

$ gcc -c nowarn.c -Wall
nowarn.c: In function ‘main’:
nowarn.c:6:9: warning: ‘e’ may be used uninitialised in this function
[-Wuninitialized]

$ gcc --version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
...

You also get the expected result if assert(f) is replace by assert(1).

Reply via email to