public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/64918] New: invalid (?) warning when initializing structure
@ 2015-02-03 13:43 oystein at gnubg dot org
2015-02-03 15:47 ` [Bug c/64918] " joseph at codesourcery dot com
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: oystein at gnubg dot org @ 2015-02-03 13:43 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: 9102 bytes --]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64918
Bug ID: 64918
Summary: invalid (?) warning when initializing structure
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: oystein at gnubg dot org
Created attachment 34651
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34651&action=edit
Code that trigger the invalid warning.
Hi!
I'm initializing a complex structure with designated initialisers and
overriding an array element (intentionally), and I then get the error message:
sideffects.c:26:13: warning: initialized field with side-effects overwritten
[3] = { .func = thefunction, .args = &((char*[]){"foo4", "bar4",
"baz4"})},
^
sideffects.c:26:13: warning: (near initialization for 'myconfig.config[3]')
However I do believe my code is correct. It complains about initializing with
side-effects, but I think my code is legal c99. (Please tell me otherwise.)
I compile the attached code with:
gcc -std=gnu99 -Wall -Wextra -Wno-override-init sideeffects.c -o sideeffects
I have tried several different versions of GCC, and here is a short summary:
GCC 4.9.2 (Arch Linux x86_64) -> Warning generated.
GCC 4.9.2 (Mingw32-w64 x86_64) -> Warning generated.
GCC 4.8.0 (Linux x86_64) -> Warning generated.
GCC 4.4.7 (Red Hat 4.4.7-4) -> No warning.
GCC 4.1.2 (Red Hat 4.1.2-52) -> No warning.
clang 3.5.1 (Arch Linux) -> No warning.
Best regards,
-Ãystein
Full info on compilers used (Those that generates warning):
[oystein@jupiter ~]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc-4.9-20141224/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-cloog-backend=isl --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu --disable-multilib
--disable-werror --enable-checking=release
Thread model: posix
gcc version 4.9.2 20141224 (prerelease) (GCC)
[14:29:03,90 c:\APPL]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/Program\
Files/mingw-w64/x86_64-4.9.2-posix-seh-rt_v3-rev1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.2/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-4.9.2/configure --host=x86_64-w64-mingw32
--build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64
--with-sysroot=/c/mingw492/x86_64-492-posix-seh-rt_v3-rev1/mingw64
--with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-shared
--enable-static --disable-multilib
--enable-languages=ada,c,c++,fortran,objc,obj-c++,lto
--enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp
--enable-libatomic --enable-lto --enable-graphite --enable-checking=release
--enable-fully-dynamic-string --enable-version-specific-runtime-libs
--disable-isl-version-check --disable-cloog-version-check
--disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap
--disable-rpath --disable-win32-registry --disable-nls --disable-werror
--disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona
--with-tune=core2 --with-libiconv --with-system-zlib
--with-gmp=/c/mingw492/prerequisites/x86_64-w64-mingw32-static
--with-mpfr=/c/mingw492/prerequisites/x86_64-w64-mingw32-static
--with-mpc=/c/mingw492/prerequisites/x86_64-w64-mingw32-static
--with-isl=/c/mingw492/prerequisites/x86_64-w64-mingw32-static
--with-cloog=/c/mingw492/prerequisites/x86_64-w64-mingw32-static
--enable-cloog-backend=isl --with-pkgversion='x86_64-posix-seh-rev1, Built by
MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64
CFLAGS='-O2 -pipe
-I/c/mingw492/x86_64-492-posix-seh-rt_v3-rev1/mingw64/opt/include
-I/c/mingw492/prerequisites/x86_64-zlib-static/include
-I/c/mingw492/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2
-pipe -I/c/mingw492/x86_64-492-posix-seh-rt_v3-rev1/mingw64/opt/include
-I/c/mingw492/prerequisites/x86_64-zlib-static/include
-I/c/mingw492/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=
LDFLAGS='-pipe -L/c/mingw492/x86_64-492-posix-seh-rt_v3-rev1/mingw64/opt/lib
-L/c/mingw492/prerequisites/x86_64-zlib-static/lib
-L/c/mingw492/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 4.9.2 (x86_64-posix-seh-rev1, Built by MinGW-W64 project)
[ojohans@st-linapp30 ~/tmp]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/private/ojohans/personal/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk-source/gcc/configure
--enable-languages=c,c++,fortran --enable-checking=release --disable-bootstrap
--disable-libmudflap --disable-libstdcxx-pch --enable-libgomp --enable-lto
--enable-gold --with-plugin-ld=/usr/bin/gold
--with-cloog-include=/usr/include-cloog --with-cloog-lib=/usr/lib64
--prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.8.0 20121206 (experimental) [trunk revision 194238] (GCC)
>From gcc-bugs-return-475879-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Feb 03 13:47:30 2015
Return-Path: <gcc-bugs-return-475879-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 18142 invoked by alias); 3 Feb 2015 13:47:29 -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 18119 invoked by uid 48); 3 Feb 2015 13:47:26 -0000
From: "tgard at opentext dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug bootstrap/64919] New: bootstrap failure of gcc-4.9.2 on ia64-hpux in libgcc
Date: Tue, 03 Feb 2015 13:47:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: bootstrap
X-Bugzilla-Version: 4.9.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: tgard at opentext 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 attachments.created
Message-ID: <bug-64919-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-02/txt/msg00212.txt.bz2
Content-length: 1604
https://gcc.gnu.org/bugzilla/show_bug.cgi?idd919
Bug ID: 64919
Summary: bootstrap failure of gcc-4.9.2 on ia64-hpux in libgcc
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: bootstrap
Assignee: unassigned at gcc dot gnu.org
Reporter: tgard at opentext dot com
Created attachment 34652
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id4652&actioníit
The command from config.log which fails
The HPUX version is 11.31
gcc-4.9.2 did not bootstrap using HPUX aCC so I installed gcc-4.7.2 and used
this.
The latest gnu assembler is used as I failed to get gcc-4.7.2 to work.
The error is:
-------------------------------
configure:3389: /builds/gbgbuild/bld/gcc/stbldh01/obj-4.9.2/./gcc/xgcc
-B/builds/gbgbuild/bld/gcc/stbldh01/obj-4.9.2/./gcc/
-B/usr/local/gcc-4.9.2/ia64-hp-hpux11.31/bin/
-B/usr/local/gcc-4.9.2/ia64-hp-hpux11.31/lib/ -isystem
/usr/local/gcc-4.9.2/ia64-hp-hpux11.31/include -isystem
/usr/local/gcc-4.9.2/ia64-hp-hpux11.31/sys-include -o conftest -g -O2
conftest.c >&5
conftest.c: In function 'main':
conftest.c:11:1: internal compiler error: Segmentation fault
main ()
^
libbacktrace could not find executable to open
Please submit a full bug report,
....
configure:3620: error: in
`/builds/gbgbuild/bld/gcc/stbldh01/obj-4.9.2/ia64-hp-hpux11.31/libgcc':
configure:3623: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details
----------------------------------
See also attachments
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/64918] invalid (?) warning when initializing structure
2015-02-03 13:43 [Bug c/64918] New: invalid (?) warning when initializing structure oystein at gnubg dot org
@ 2015-02-03 15:47 ` joseph at codesourcery dot com
2015-02-03 16:38 ` oystein at gnubg dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: joseph at codesourcery dot com @ 2015-02-03 15:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64918
--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
I think the logical side-effect in C standard terms of the initializer
being overridden is that it contains a compound literal, and so executing
that initializer has the side-effect of initializing that compound literal
(compound literal initializers being executed each time the compound
literal is reached in the order of execution). The warning is because
it's unspecified whether overridden initializers are executed at all, and
so whether their side-effects occur - but in this case it's maybe not so
helpful, because the compound literal in the overridden initializer can't
actually be accessed so it doesn't matter if the side-effect of
initializing it gets lost (unless any of its initializers contained other
side-effects, which they don't in this case).
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/64918] invalid (?) warning when initializing structure
2015-02-03 13:43 [Bug c/64918] New: invalid (?) warning when initializing structure oystein at gnubg dot org
2015-02-03 15:47 ` [Bug c/64918] " joseph at codesourcery dot com
@ 2015-02-03 16:38 ` oystein at gnubg dot org
2015-02-03 17:33 ` joseph at codesourcery dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: oystein at gnubg dot org @ 2015-02-03 16:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64918
--- Comment #2 from Øystein Schønning-Johansen <oystein at gnubg dot org> ---
Really insightful, Joseph. I do understand the warning a bit better now. I have
not looked into the GCC parsing code, but based on your description and my
(limited) understanding of the problem, I guess a fix is not trivial? Can I
suppress this warning in any way?
-Ø
>From gcc-bugs-return-475899-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Feb 03 16:49:15 2015
Return-Path: <gcc-bugs-return-475899-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 1652 invoked by alias); 3 Feb 2015 16:49:15 -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 1544 invoked by uid 48); 3 Feb 2015 16:49:11 -0000
From: "segher at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/54303] -fdata-sections -ffunction-sections and -fmerge-constants do not work well together
Date: Tue, 03 Feb 2015 16:49:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: 4.6.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: segher at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: segher at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc assigned_to bug_severity
Message-ID: <bug-54303-4-pvysdPdp26@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-54303-4@http.gcc.gnu.org/bugzilla/>
References: <bug-54303-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-02/txt/msg00232.txt.bz2
Content-length: 539
https://gcc.gnu.org/bugzilla/show_bug.cgi?idT303
Segher Boessenkool <segher at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |segher at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |segher at gcc dot gnu.org
Severity|normal |enhancement
--- Comment #14 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Mine.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/64918] invalid (?) warning when initializing structure
2015-02-03 13:43 [Bug c/64918] New: invalid (?) warning when initializing structure oystein at gnubg dot org
2015-02-03 15:47 ` [Bug c/64918] " joseph at codesourcery dot com
2015-02-03 16:38 ` oystein at gnubg dot org
@ 2015-02-03 17:33 ` joseph at codesourcery dot com
2015-04-20 15:14 ` mpolacek at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: joseph at codesourcery dot com @ 2015-02-03 17:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64918
--- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
There isn't currently an option to disable this warning.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/64918] invalid (?) warning when initializing structure
2015-02-03 13:43 [Bug c/64918] New: invalid (?) warning when initializing structure oystein at gnubg dot org
` (2 preceding siblings ...)
2015-02-03 17:33 ` joseph at codesourcery dot com
@ 2015-04-20 15:14 ` mpolacek at gcc dot gnu.org
2015-04-23 22:44 ` mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-04-20 15:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64918
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Could be fixed with adding -Woverride-init-side-effects, but not sure if it's
worth it.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/64918] invalid (?) warning when initializing structure
2015-02-03 13:43 [Bug c/64918] New: invalid (?) warning when initializing structure oystein at gnubg dot org
` (3 preceding siblings ...)
2015-04-20 15:14 ` mpolacek at gcc dot gnu.org
@ 2015-04-23 22:44 ` mpolacek at gcc dot gnu.org
2015-04-23 23:33 ` manu at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-04-23 22:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64918
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2015-04-23
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Target Milestone|--- |6.0
Ever confirmed|0 |1
--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Patch posted.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/64918] invalid (?) warning when initializing structure
2015-02-03 13:43 [Bug c/64918] New: invalid (?) warning when initializing structure oystein at gnubg dot org
` (4 preceding siblings ...)
2015-04-23 22:44 ` mpolacek at gcc dot gnu.org
@ 2015-04-23 23:33 ` manu at gcc dot gnu.org
2015-05-07 22:15 ` mpolacek at gcc dot gnu.org
2021-01-05 16:57 ` mpolacek at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: manu at gcc dot gnu.org @ 2015-04-23 23:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64918
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Øystein Schønning-Johansen from comment #2)
> Really insightful, Joseph. I do understand the warning a bit better now. I
> have not looked into the GCC parsing code, but based on your description and
> my (limited) understanding of the problem, I guess a fix is not trivial? Can
> I suppress this warning in any way?
I haven't looked at the code, but my guess is that at the time of the warning,
it should be possible to check the overriden initializer, if it is a compound
literal, recur on its initializers and check for side-effects again.
>From gcc-bugs-return-484532-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Apr 23 23:34:38 2015
Return-Path: <gcc-bugs-return-484532-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 39032 invoked by alias); 23 Apr 2015 23:34:37 -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 39010 invoked by uid 48); 23 Apr 2015 23:34:33 -0000
From: "jamrial at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/65871] New: bzhi builtin/intrinsic wrongly assumes bzhi instruction doesn't set the ZF flag
Date: Thu, 23 Apr 2015 23:34: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: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jamrial 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-65871-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/msg02084.txt.bz2
Content-length: 1753
https://gcc.gnu.org/bugzilla/show_bug.cgi?ide871
Bug ID: 65871
Summary: bzhi builtin/intrinsic wrongly assumes bzhi
instruction doesn't set the ZF flag
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: jamrial at gmail dot com
unsigned foo(void);
int main(void)
{
if (__builtin_ia32_bzhi_si(foo(), foo()))
return 1;
return 0;
}
Compiled with -mbmi2 -O3
0000000000000000 <main>:
0: 53 push rbx
1: e8 00 00 00 00 call 6 <main+0x6>
6: 89 c3 mov ebx,eax
8: e8 00 00 00 00 call d <main+0xd>
d: c4 e2 60 f5 c0 bzhi eax,eax,ebx
12: 85 c0 test eax,eax
14: 0f 95 c0 setne al
17: 0f b6 c0 movzx eax,al
1a: 5b pop rbx
1b: c3 ret
It generates a redundant test instruction. According to
http://www.felixcloutier.com/x86/BZHI.html bzhi already sets the ZF flag on its
own.
Same happens when using inline assembly instead of the builtin to generate the
bzhi instruction. In all cases reproducible with GCC 4.9.2 and GCC 5.1.0.
Didn't test the 4.8 branch or trunk.
This aside, it would be nice if gcc could generate a bzhi instruction on its
own if it detects "X & ((1 << Y) - 1)" where Y is not a constant, same as it
does for several other bmi and tbm instructions, instead of needing to use the
builtin (Which is only available when targeting bmi2).
I can open a new bug report for that if needed.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/64918] invalid (?) warning when initializing structure
2015-02-03 13:43 [Bug c/64918] New: invalid (?) warning when initializing structure oystein at gnubg dot org
` (5 preceding siblings ...)
2015-04-23 23:33 ` manu at gcc dot gnu.org
@ 2015-05-07 22:15 ` mpolacek at gcc dot gnu.org
2021-01-05 16:57 ` mpolacek at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-05-07 22:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64918
--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Thu May 7 22:14:27 2015
New Revision: 222894
URL: https://gcc.gnu.org/viewcvs?rev=222894&root=gcc&view=rev
Log:
PR c/64918
* c.opt (Woverride-init-side-effects): New option.
* c-typeck.c (add_pending_init): Use OPT_Woverride_init_side_effects.
(output_init_element): Likewise.
* doc/invoke.texi: Document -Woverride-init-side-effects.
* gcc.dg/Woverride-init-side-effects-1.c: New test.
* gcc.dg/Woverride-init-side-effects-2.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/Woverride-init-side-effects-1.c
trunk/gcc/testsuite/gcc.dg/Woverride-init-side-effects-2.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c.opt
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-typeck.c
trunk/gcc/doc/invoke.texi
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/64918] invalid (?) warning when initializing structure
2015-02-03 13:43 [Bug c/64918] New: invalid (?) warning when initializing structure oystein at gnubg dot org
` (6 preceding siblings ...)
2015-05-07 22:15 ` mpolacek at gcc dot gnu.org
@ 2021-01-05 16:57 ` mpolacek at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-01-05 16:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64918
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #11 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-01-05 16:57 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-03 13:43 [Bug c/64918] New: invalid (?) warning when initializing structure oystein at gnubg dot org
2015-02-03 15:47 ` [Bug c/64918] " joseph at codesourcery dot com
2015-02-03 16:38 ` oystein at gnubg dot org
2015-02-03 17:33 ` joseph at codesourcery dot com
2015-04-20 15:14 ` mpolacek at gcc dot gnu.org
2015-04-23 22:44 ` mpolacek at gcc dot gnu.org
2015-04-23 23:33 ` manu at gcc dot gnu.org
2015-05-07 22:15 ` mpolacek at gcc dot gnu.org
2021-01-05 16:57 ` mpolacek 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).