public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/115527] New: -ftrivial-auto-var-init appears to clobber explicit initializer
@ 2024-06-17 19:33 nora at norasandler dot com
2024-06-17 22:22 ` [Bug middle-end/115527] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: nora at norasandler dot com @ 2024-06-17 19:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115527
Bug ID: 115527
Summary: -ftrivial-auto-var-init appears to clobber explicit
initializer
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: nora at norasandler dot com
Target Milestone: ---
This program behaves incorrectly when compiled with -ftrivial-auto-var=pattern
or -ftrivial-auto-var=zero:
// Bug in GCC -ftrivial-auto-var
struct inner {
double a;
char b;
long l;
};
struct outer {
struct inner in_array[3];
int bar;
};
int main(void) {
struct inner si = {1., 0, 0};
struct outer o = {// in_array
{
si,
{0, 0, 0},
{0, 0, 0},
},
// bar
0};
if (o.in_array[0].a != 1.) {
return 1; // fail
}
return 0;
}
Without the -ftrivial-auto-var option, this returns 0, as expected. With
-ftrivial-auto-var=pattern or -ftrivial-auto-var=zero it returns 1:
$ gcc -ftrivial-auto-var-init=pattern auto-var-bug.c
$ ./a.out
$ echo $?
1
$ gcc auto-var-bug.c
$ ./a.out
$ echo $?
0
I saw this behavior in GCC 13.1.0, 13.2.0, and 14.0.1 (I haven't tried it with
other versions).
Full version info for the version of 13.2.0 I tested this with:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
13.2.0-23ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-13
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify
--enable-plugin --enable-default-pie --with-system-zlib
--enable-libphobos-checking=release --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-13-uJ7kn6/gcc-13-13.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-13-uJ7kn6/gcc-13-13.2.0/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Ubuntu 13.2.0-23ubuntu4)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/115527] -ftrivial-auto-var-init appears to clobber explicit initializer
2024-06-17 19:33 [Bug c/115527] New: -ftrivial-auto-var-init appears to clobber explicit initializer nora at norasandler dot com
@ 2024-06-17 22:22 ` pinskia at gcc dot gnu.org
2024-06-18 14:40 ` qinzhao at gcc dot gnu.org
2024-06-21 14:32 ` sjames at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-17 22:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115527
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2024-06-17
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. It looks like the option is emitting the code afterwards rather than
before the initializer ...
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/115527] -ftrivial-auto-var-init appears to clobber explicit initializer
2024-06-17 19:33 [Bug c/115527] New: -ftrivial-auto-var-init appears to clobber explicit initializer nora at norasandler dot com
2024-06-17 22:22 ` [Bug middle-end/115527] " pinskia at gcc dot gnu.org
@ 2024-06-18 14:40 ` qinzhao at gcc dot gnu.org
2024-06-21 14:32 ` sjames at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2024-06-18 14:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115527
qinzhao at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |qinzhao at gcc dot gnu.org
--- Comment #2 from qinzhao at gcc dot gnu.org ---
(In reply to Andrew Pinski from comment #1)
> Confirmed. It looks like the option is emitting the code afterwards rather
> than before the initializer ...
Yes, this is the case, will take a look on why this is happening.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/115527] -ftrivial-auto-var-init appears to clobber explicit initializer
2024-06-17 19:33 [Bug c/115527] New: -ftrivial-auto-var-init appears to clobber explicit initializer nora at norasandler dot com
2024-06-17 22:22 ` [Bug middle-end/115527] " pinskia at gcc dot gnu.org
2024-06-18 14:40 ` qinzhao at gcc dot gnu.org
@ 2024-06-21 14:32 ` sjames at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-21 14:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115527
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-06-21 14:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-17 19:33 [Bug c/115527] New: -ftrivial-auto-var-init appears to clobber explicit initializer nora at norasandler dot com
2024-06-17 22:22 ` [Bug middle-end/115527] " pinskia at gcc dot gnu.org
2024-06-18 14:40 ` qinzhao at gcc dot gnu.org
2024-06-21 14:32 ` sjames 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).