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]

[Bug c/57407] New: Missing uninitialized warning following assert


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).

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