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
* [Bug tree-optimization/59970] Bogus warnings at low optimization levels
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 ` pinskia at gcc dot gnu.org
2014-04-25 1:36 ` matt at godbolt dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-01-28 21:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59970
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |tree-optimization
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I don't think this is a GCC bug except for the unitialized predicates is not
working. The reason why it fails for -Og is because jump threading is disabled
as you want to be able to step through the code. -O1 must not decided jump
threading is profitable either.
For the unitialized predicates issue, it might be because switch statements are
not handled.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/59970] Bogus warnings at low optimization levels
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
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: matt at godbolt dot org @ 2014-04-25 1:36 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 4303 bytes --]
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59970
Matt Godbolt <matt at godbolt dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |matt at godbolt dot org
--- Comment #2 from Matt Godbolt <matt at godbolt dot org> ---
FWIW I stumbled over what I believe is the same issue inside the boost v1.55.0
lexical_cast implementation. That also only shows up as a "possible
uninitialized" at -Og optimization only. I can provide preprocessed source if
necessary (though, being boost, it's 80k lines, ugh) but if you have gcc4.9.0
and boost 1.55 available:
$ cat test.cc
#include <boost/lexical_cast.hpp>
int test() { return boost::lexical_cast<int>("1"); }
$ g++ -Wall -Wextra -Og -c test.cc
test.cc: In function âint test()â:
test.cc:4:40: warning: âresultâ may be used uninitialized in this function
[-Wmaybe-uninitialized]
return boost::lexical_cast<int>("1");
The relevant lines in boost itself appear to be
http://svn.boost.org/svn/boost/tags/release/Boost_1_55_0/boost/lexical_cast.hpp
lines 2365-2377 where the "result" is optionally initialized.
I'll also submit this to the boost developers in case they have some ideas.
>From gcc-bugs-return-449836-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Apr 25 02:03:00 2014
Return-Path: <gcc-bugs-return-449836-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 11701 invoked by alias); 25 Apr 2014 02:02:59 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 28410 invoked by uid 48); 25 Apr 2014 02:01:01 -0000
From: "anton at samba dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug go/60931] libgo has issues when page size is not 4k
Date: Fri, 25 Apr 2014 02:02:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: go
X-Bugzilla-Version: 4.10.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: anton at samba dot org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: ian at airs dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: attachments.isobsolete attachments.created
Message-ID: <bug-60931-4-VHFuKDergr@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60931-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60931-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-04/txt/msg01856.txt.bz2
Content-length: 1173
http://gcc.gnu.org/bugzilla/show_bug.cgi?id`931
Anton Blanchard <anton at samba dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #32669|0 |1
is obsolete| |
--- Comment #7 from Anton Blanchard <anton at samba dot org> ---
Created attachment 32679
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id2679&actioníit
runtime: Fix garbage collector issue with non 4kB system page size
The go garbage collector tracks memory in terms of 4kB pages. Most of
the code checks getpagesize() at runtime and does the right thing.
On a 64kB ppc64 box I see SEGVs in long running processes which has
been diagnosed as a bug in scavengelist. scavengelist does a
madvise(MADV_DONTNEED) without rounding the arguments to the system
page size. A strace of one of the failures shows the problem:
madvise(0xc211030000, 4096, MADV_DONTNEED) = 0
The kernel rounds the length up to 64kB and we mark 60kB of valid data
as no longer needed.
Round start up to a system page and end down before calling madvise.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/59970] Bogus warnings at low optimization levels
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
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mac at mcrowe dot com @ 2015-04-22 13:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59970
Mike Crowe <mac at mcrowe dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mac at mcrowe dot com
--- Comment #3 from Mike Crowe <mac at mcrowe dot com> ---
Created attachment 35384
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35384&action=edit
Preprocessed source for boost::lexical_cast case
I can reproduce the same problem with Debian Jessie's gcc 4.9.2 and a
self-compiled gcc 4.9.1 when compiling:
#include <boost/lexical_cast.hpp>
int wibble()
{
return boost::lexical_cast<int>("1");
}
Preprocessed source attached (compressed to avoid file size limit.)
$ g++ -Wall -Werror -Og -save-temps test.cpp
test.cpp: In function ‘int wibble()’:
test.cpp:5:40: error: ‘result’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
return boost::lexical_cast<int>("1");
^
cc1plus: all warnings being treated as errors
Oddly the warning is not reported when the function is named "main"!
>From gcc-bugs-return-484355-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Apr 22 13:50:38 2015
Return-Path: <gcc-bugs-return-484355-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 51867 invoked by alias); 22 Apr 2015 13:50:38 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 51394 invoked by uid 48); 22 Apr 2015 13:50:34 -0000
From: "jay.foad at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/65847] New: SSE2 code for adding two structs is much worse at -O3 than at -O2
Date: Wed, 22 Apr 2015 13:50:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jay.foad at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-65847-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-04/txt/msg01907.txt.bz2
Content-length: 1519
https://gcc.gnu.org/bugzilla/show_bug.cgi?ide847
Bug ID: 65847
Summary: SSE2 code for adding two structs is much worse at -O3
than at -O2
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: jay.foad at gmail dot com
On x86_64 I get decent code at -O2:
$ cat zplus.c
typedef struct { double a, b; } Z;
Z zplus(Z x, Z y) { return (Z){ x.a + y.a, x.b + y.b }; }
$ gcc -O2 -S -o - zplus.c
...
zplus:
.LFB0:
.cfi_startproc
addsd %xmm3, %xmm1
addsd %xmm2, %xmm0
ret
.cfi_endproc
.LFE0:
...
but awful code at -O3:
$ gcc -O3 -S -o - zplus.c
...
zplus:
.LFB0:
.cfi_startproc
movq %xmm0, -40(%rsp)
movq %xmm1, -32(%rsp)
movq %xmm2, -56(%rsp)
movq %xmm3, -48(%rsp)
movupd -40(%rsp), %xmm1
movupd -56(%rsp), %xmm0
addpd %xmm0, %xmm1
movaps %xmm1, -72(%rsp)
movq -72(%rsp), %rdx
movq -64(%rsp), %rax
movq %rdx, -72(%rsp)
movsd -72(%rsp), %xmm0
movq %rax, -72(%rsp)
movsd -72(%rsp), %xmm1
ret
...
I see similar bad code generated by various versions of GCC, starting around
version 4.8:
gcc-4.8 (Ubuntu 4.8.3-12ubuntu3) 4.8.3
gcc (Ubuntu 4.9.1-16ubuntu6) 4.9.1
gcc (GCC) 6.0.0 20150422 (experimental)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/59970] Bogus warnings at low optimization levels
2014-01-28 21:06 [Bug middle-end/59970] New: Bogus warnings at low optimization levels tschwinge at gcc dot gnu.org
` (2 preceding siblings ...)
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
5 siblings, 0 replies; 7+ messages in thread
From: mac at mcrowe dot com @ 2015-04-22 16:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59970
--- Comment #4 from Mike Crowe <mac at mcrowe dot com> ---
The test case in comment #3 shows the same problem in gcc-5-branch r222333.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/59970] Bogus Wuninitialized warnings at low optimization levels
2014-01-28 21:06 [Bug middle-end/59970] New: Bogus warnings at low optimization levels tschwinge at gcc dot gnu.org
` (3 preceding siblings ...)
2015-04-22 16:56 ` mac at mcrowe dot com
@ 2021-03-26 22:27 ` msebor at gcc dot gnu.org
2021-03-26 22:40 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-26 22:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59970
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |7.0
CC| |msebor at gcc dot gnu.org
Known to fail| |4.8.4, 4.9.4, 5.5.0, 6.4.0
Keywords| |diagnostic
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Martin Sebor <msebor at gcc dot gnu.org> ---
The test case in comment #0 is not diagnosed anymore. Bisection points to
r240221 as the fix. Ditto for attachment 35384 from comment #3. Let me add
the one from attachment 31970 to the test suite and resolve this as fixed.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/59970] Bogus Wuninitialized warnings at low optimization levels
2014-01-28 21:06 [Bug middle-end/59970] New: Bogus warnings at low optimization levels tschwinge at gcc dot gnu.org
` (4 preceding siblings ...)
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
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-26 22:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59970
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:
https://gcc.gnu.org/g:980b12cc81979e52f491bf0dfe961d30c07fe864
commit r11-7869-g980b12cc81979e52f491bf0dfe961d30c07fe864
Author: Martin Sebor <msebor@redhat.com>
Date: Fri Mar 26 16:37:34 2021 -0600
PR tree-optimization/59970 - Bogus -Wmaybe-uninitialized at low
optimization levels
PR tree-optimization/59970
* gcc.dg/uninit-pr59970.c: New test.
^ 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).