[Bug c/70765] New: GCC fails to detect possibly uninitialized variable

2016-04-22 Thread mike at conlen dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70765

Bug ID: 70765
   Summary: GCC fails to detect possibly uninitialized variable
   Product: gcc
   Version: 5.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mike at conlen dot org
  Target Milestone: ---

Created attachment 38329
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38329&action=edit
main() .i file

GCC without an optimization option does not catch a situation where a variable
is used uninitialized (with -Wall -Werror). I can cause gcc to catch this
situation by making the function call which involves passing the unused
variable a call to a function in another translation unit. 

Compiler: 

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/mconlen/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-5.3.0/configure --prefix=/home/mconlen
--enable-languages=all
Thread model: posix
gcc version 5.3.0 (GCC) 
$

System Type: 

$ uname -a
Linux bos-lprll 3.13.0-83-generic #127-Ubuntu SMP Fri Mar 11 00:25:37 UTC 2016
x86_64 x86_64 x86_64 GNU/Linux
$

Building commands: 

$ gcc -Wall -Wextra -Werror -save-temps -c test.c
$ gcc -Wall -Wextra -Werror -save-temps -c af.c
$ gcc -Wall -Werror -o test test.o af.o

Compiler output: None

.i files: attached

[Bug c/70765] GCC fails to detect possibly uninitialized variable

2016-04-22 Thread mike at conlen dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70765

--- Comment #1 from Mike Conlen  ---
Created attachment 38330
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38330&action=edit
a second translation unit

Using the second translation unit will cause the compilation to error (as
expected) with -O3

[Bug c/70765] GCC fails to detect possibly uninitialized variable

2016-04-22 Thread mike at conlen dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70765

--- Comment #2 from Mike Conlen  ---
If I compile with -O3 the compiler produces (as expected)

$ gcc -Wall -Wextra -Werror -save-temps -O3 -c test.c
test.c: In function 'try_to_fail':
test.c:25:2: error: 'data' is used uninitialized in this function
[-Werror=uninitialized]
  arbitrary_function(data);
  ^
test.c: In function 'main':
test.c:25:2: error: 'data' is used uninitialized in this function
[-Werror=uninitialized]
test.c:18:7: note: 'data' was declared here
  int *data;
   ^
cc1: all warnings being treated as errors