Bug 49848 - False positive warning triggered by -Wmaybe-uninitialized
Summary: False positive warning triggered by -Wmaybe-uninitialized
Status: RESOLVED DUPLICATE of bug 42145
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.5.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2011-07-26 01:29 UTC by Arnaud Lacombe
Modified: 2014-11-25 14:10 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-10-25 00:00:00


Attachments
reduced testcase (117 bytes, text/x-csrc)
2011-07-26 01:31 UTC, Arnaud Lacombe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arnaud Lacombe 2011-07-26 01:29:35 UTC
Considering the attached reduced-testcase, gcc will trigger the following warning:

% gcc -m32 -Wall -Os -c -S -o /dev/null foo.c                                                                  
foo.c: In function 'foo':
foo.c:9:12: warning: 'b' may be used uninitialized in this function

Affected gcc is:

% gcc -v                                     
Using built-in specs.
[...]
Thread model: posix
gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC)

however, gcc from trunk (as of 20110609) also produces the warning:

/src/x86-64/obj/destdir/bin/x86_64-none-linux-gcc -m32 -Wall -Os -c -S -o /dev/null foo.c
foo.c: In function 'foo':
foo.c:14:21: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]

This warning only shows up at -Os.

Mailing list reference: http://gcc.gnu.org/ml/gcc-help/2011-07/msg00243.html
Comment 1 Arnaud Lacombe 2011-07-26 01:31:07 UTC
Created attachment 24834 [details]
reduced testcase
Comment 2 Andrew Pinski 2011-07-26 02:15:38 UTC
This is a semi standard issue with uninitialized variable warnings.
Comment 3 Manuel López-Ibáñez 2012-10-25 00:12:34 UTC
Still present in GCC 4.8.0pr49848.c: In function ‘foo’:
pr49848.c:14:21: warning: ‘b’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (a != NULL && b != NULL)
                     ^
Comment 4 Jeffrey A. Law 2013-11-20 01:12:56 UTC
Another case where throttling optimizations inhibits accurate warnings.

*** This bug has been marked as a duplicate of bug 42145 ***