public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/59970] New: Bogus warnings at low optimization levels
@ 2014-01-28 21:06 tschwinge at gcc dot gnu.org
  2014-01-28 21:22 ` [Bug tree-optimization/59970] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2014-01-28 21:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59970

            Bug ID: 59970
           Summary: Bogus warnings at low optimization levels
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: middle-end
          Assignee: tschwinge at gcc dot gnu.org
          Reporter: tschwinge at gcc dot gnu.org
             Build: x86_64-linux-gnu

Created attachment 31970
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31970&action=edit
cp-demangle.c

The attached code is greatly reduced from libiberty/cp-demangle.c.  As
discussed in
<http://news.gmane.org/find-root.php?message_id=%3C87bnyw41hf.fsf%40kepler.schwinge.homeip.net%3E>,
with trunk r207200, it exhibits the following behavior:

    $ for t in '' -DTOGGLE1; do for a in '' -DABORT; do for o in -O0 -Og -O1
-O2 -O3 -Ofast; do (set -x && gcc/xgcc -Bgcc/ -Wall -Wextra -c
../../cp-demangle.c $t $a $o); done; done; done
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -O0
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -Og
    ../../cp-demangle.c: In function 'd_demangle_callback':
    ../../cp-demangle.c:40:3: warning: 'dc' may be used uninitialized in this
function [-Wmaybe-uninitialized]
       return dc;
       ^
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -O1
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -O2
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -O3
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -Ofast
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DABORT -O0
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DABORT -Og
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DABORT -O1
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DABORT -O2
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DABORT -O3
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DABORT -Ofast
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -O0
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -Og
    ../../cp-demangle.c: In function 'd_demangle_callback':
    ../../cp-demangle.c:40:3: warning: 'dc' may be used uninitialized in this
function [-Wmaybe-uninitialized]
       return dc;
       ^
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -O1
    ../../cp-demangle.c: In function 'd_demangle_callback':
    ../../cp-demangle.c:40:3: warning: 'dc' may be used uninitialized in this
function [-Wmaybe-uninitialized]
       return dc;
       ^
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -O2
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -O3
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -Ofast
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -DABORT
-O0
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -DABORT
-Og
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -DABORT
-O1
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -DABORT
-O2
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -DABORT
-O3
    + gcc/xgcc -Bgcc/ -Wall -Wextra -c ../../cp-demangle.c -DTOGGLE1 -DABORT
-Ofast

In certain cases, GCC fails to track that all the possible values for enum type
indeed have been covered, and so dc must have been initialized.

It does seem appropriate to me for GCC not to do such tracking at low
optimization levels, but then the uninitialized warning should also be disabled
(which I assume is happening for -O0?) to avoid false positive warnings.

The abort to libiberty/cp-demangle.c has been added in r207200.  The
libgomp/env.c change r203514 looks like another instance of this issue,
<http://news.gmane.org/find-root.php?message_id=%3C20131014082733.GF30970%40tucnak.zalov.cz%3E>.

I'm assigning this to me, tentatively, low priority, so if someone has any
clues, don't hesititate to take it over.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-03-26 22:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-28 21:06 [Bug middle-end/59970] New: Bogus warnings at low optimization levels tschwinge at gcc dot gnu.org
2014-01-28 21:22 ` [Bug tree-optimization/59970] " pinskia at gcc dot gnu.org
2014-04-25  1:36 ` matt at godbolt dot org
2015-04-22 13:39 ` mac at mcrowe dot com
2015-04-22 16:56 ` mac at mcrowe dot com
2021-03-26 22:27 ` [Bug tree-optimization/59970] Bogus Wuninitialized " msebor at gcc dot gnu.org
2021-03-26 22:40 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).