https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92427

            Bug ID: 92427
           Summary: Initializing an element which has a zero-length array
                    of a type-with-destructor causes an internal compiler
                    error
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nmehrotra at riorey dot com
  Target Milestone: ---

Declaring and trying to initialize an element which has a zero-length array,
which itself is of a type that has a destructor, causes an internal compiler
error.

Proprocessed code:
------------------

# 1 "zz.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "zz.cpp"
class C {
private:
    int a; int b;
public:
    C(int A, int B) : a(A), b(B) { }
    ~C() { }
};

struct y {
    int a; C b[];
} y = { 1, { { 2, 3 } } };

int main(void) { return 0; }


The error message:
------------------

zz.cpp: In function ‘void __static_initialization_and_destruction_0(int, int)’:
zz.cpp:11:3: internal compiler error: in finish_expr_stmt, at
cp/semantics.c:680
 } y = { 1, { { 2, 3 } } };
   ^
0x7f802a629e5a __libc_start_main
        ../csu/libc-start.c:308
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.

The command line:
-----------------
gcc zz.cpp


Compiler:
---------
gcc -v zz.cpp
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/8.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-8.3.0-r1/work/gcc-8.3.0/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/8.3.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/8.3.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/8.3.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/8.3.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/8.3.0/python
--enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt
--disable-werror --with-system-zlib --enable-nls --without-included-gettext
--enable-checking=release --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion='Gentoo 8.3.0-r1 p1.1' --disable-esp --enable-libstdcxx-time
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64
--disable-altivec --disable-fixed-point --enable-targets=all --enable-libgomp
--disable-libmudflap --disable-libssp --disable-libmpx --disable-systemtap
--enable-vtable-verify --enable-lto --without-isl --enable-default-pie
--enable-default-ssp
Thread model: posix
gcc version 8.3.0 (Gentoo 8.3.0-r1 p1.1) 
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-pc-linux-gnu/8.3.0/cc1plus -quiet -v -D_GNU_SOURCE
zz.cpp -quiet -dumpbase zz.cpp -mtune=generic -march=x86-64 -auxbase zz
-version -o /tmp/ccBqkqu4.s
GNU C++14 (Gentoo 8.3.0-r1 p1.1) version 8.3.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 3.1.6,
MPC version 1.0.3, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8
 /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/x86_64-pc-linux-gnu
 /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/backward
 /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include-fixed
 /usr/include
End of search list.
GNU C++14 (Gentoo 8.3.0-r1 p1.1) version 8.3.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 3.1.6,
MPC version 1.0.3, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 8330a0e4e33b5f386c6a540b63a52c5e

System:
-------

Linux buildm68 4.19.57-gentoo #2 SMP Thu Jul 18 20:31:51 UTC 2019 x86_64
Intel(R) Xeon(R) CPU E3-1220 V2 @ 3.10GHz GenuineIntel GNU/Linux

qlist -IRv|grep gcc
sys-devel/gcc-8.3.0-r1::gentoo
sys-devel/gcc-config-2.0::gentoo

------------------------------------------------------------------------------

The problem appears to be caused by the fact that gcc can't determine at
compile time the number of elements to be destroyed.  

Removing the destructor from the class definition fixes the failure.

Reply via email to