This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/57407] New: Missing uninitialized warning following assert
- From: "stuff0003 at pobox dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 25 May 2013 01:39:28 +0000
- Subject: [Bug c/57407] New: Missing uninitialized warning following assert
- Auto-submitted: auto-generated
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).