https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93496
Bug ID: 93496
Summary: Miscompile of range-for over braced-init-list in
constructor of class with virtual inheritance
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: justin.lapolla.hpe at gmail dot com
Target Milestone: ---
Created attachment 47733
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47733&action=edit
test.ii
When I compile, link, and run the attached test.ii file, I expect the
executable to exit with status 0. Instead, it exits with status 1.
Debugging in GDB shows that the _M_len member of the braced-init-list is not
set correctly. I noticed in the assembly code that _ZN3BarC2Ev correctly sets
_M_len while _ZN3BarC1Ev does not.
Here is the correct code from _ZN3BarC2Ev:
movl $0x0,-0x34(%rbp) # Set braced-init-list data
movq $0x0,-0x30(%rbp) # Zero out _M_addr
movq $0x0,-0x28(%rbp) # Zero out _M_len
movq $0x1,-0x28(%rbp) # Set _M_len
lea-0x34(%rbp),%rax
mov%rax,-0x30(%rbp) # Set _M_addr
Here is the incorrect code from _ZN3BarC1Ev:
movl $0x0,-0x34(%rbp) # Set braced-init-list data
movq $0x0,-0x30(%rbp) # Zero out _M_addr
movq $0x0,-0x28(%rbp) # Zero out _M_len
# instruction to set _M_len
lea-0x34(%rbp),%rax
mov%rax,-0x30(%rbp) # Set _M_addr
Version:
---
GNU C++14 (GCC) version 8.1.0 20180502 (Cray Inc.) (x86_64-suse-linux)
compiled by GNU C version 8.1.0 20180502 (Cray Inc.), GMP version
6.0.0, MPFR version 3.1.3, MPC version 1.0.3, isl version isl-0.15-GMP
---
System type:
---
x86_64-suse-linux
---
Configured with:
---
../cray-gcc-8.1.0-201806150759.6677a227493f2/configure
--prefix=/opt/gcc/8.1.0/snos --disable-nls --libdir=/opt/gcc/8.1.0/snos/lib
--enable-languages=c,c++,fortran
--with-gxx-include-dir=/opt/gcc/8.1.0/snos/include/g++
--with-slibdir=/opt/gcc/8.1.0/snos/lib --with-system-zlib --enable-shared
--enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog
--disable-multilib
---
Command line that triggers the bug:
---
g++ test.ii
---
Compiler output (empty):
---
---