Bug 60294 - missing diagnostic with -Wmaybe-uninitialized
Summary: missing diagnostic with -Wmaybe-uninitialized
Status: RESOLVED DUPLICATE of bug 59223
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.8.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-20 22:21 UTC by Martin Sebor
Modified: 2014-02-26 17:55 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2014-02-20 22:21:17 UTC
The documentation for the -Wmaybe-uninitialized option includes an example similar to the one below to demonstrate the conditions under which GCC is expected to issue a diagnostic. However, GCC fails to issue the expected diagnostic when the option is used (it does issue it with -Wall, -Wextra, and, contrary to expectations, with -Wuninitialized).

$ (set -x && cat t.c && for w in all extra uninitialized maybe-uninitialized; do gcc -O2 -Werror -W$w -c -o/dev/null t.c && echo success; done)
+ cat t.c
void foo (int);
void bar (int y) {
    int x;
    switch (y)
    {
    case 1: x = 1;
            break;
    case 2: x = 4;
            break;
    case 3: x = 5;
    }
    foo (x);
}
+ for w in all extra uninitialized maybe-uninitialized
+ gcc -O2 -Werror -Wall -c -o/dev/null t.c
t.c: In function ‘bar’:
t.c:12:9: error: ‘x’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     foo (x);
         ^
cc1: all warnings being treated as errors
+ for w in all extra uninitialized maybe-uninitialized
+ gcc -O2 -Werror -Wextra -c -o/dev/null t.c
t.c: In function ‘bar’:
t.c:12:9: error: ‘x’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     foo (x);
         ^
cc1: all warnings being treated as errors
+ for w in all extra uninitialized maybe-uninitialized
+ gcc -O2 -Werror -Wuninitialized -c -o/dev/null t.c
t.c: In function ‘bar’:
t.c:12:9: error: ‘x’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     foo (x);
         ^
cc1: all warnings being treated as errors
+ for w in all extra uninitialized maybe-uninitialized
+ gcc -O2 -Werror -Wmaybe-uninitialized -c -o/dev/null t.c
+ echo success
success
Comment 1 Marek Polacek 2014-02-26 17:55:06 UTC
Seems like a dup.

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