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

            Bug ID: 89214
           Summary: ICE in digest_init_r, at cp/typeck2.c:1211 with
                    -std=c++17
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qdlacz at gmail dot com
  Target Milestone: ---

The following c++17 code fails to build on g++ 9.0.1, but builds fine on g++
(GCC) 8.2.1 20181215 (Red Hat 8.2.1-6).

Details about g++ 9.0.1:

~/gcc-trunk/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/home/krnowak/gcc-trunk/bin/g++
COLLECT_LTO_WRAPPER=/home/krnowak/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/9.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/krnowak/projects/gcc/trunk/build/../src/configure
--prefix=/home/krnowak/gcc-trunk --enable-languages=c,c++ : (reconfigured)
/home/krnowak/projects/gcc/trunk/build/../src/configure
--prefix=/home/krnowak/gcc-trunk --enable-languages=c,c++
Thread model: posix
gcc version 9.0.1 20190205 (experimental) (GCC)

Details about g++ 8.2.1:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array --with-isl --enable-libmpx
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-gnu-indirect-function --enable-cet --with-tune=generic
--with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.2.1 20181215 (Red Hat 8.2.1-6) (GCC) 



I compiled the code with -std=c++17 -Wall -Wextra -Wpedantic. Adding -DOK
causes the compilation to succeed.


struct A
{
  template <typename U>
  A (U&&);
};

#ifdef OK
struct B
{
  A v;
};
#else
struct BB
{
  A v;
};

struct B : BB
{};
#endif

auto
foo () -> B
{
  return {{B {{42}}}};
}



Backtrace I'm getting:


./test.cc: In function ‘B foo()’:
./test.cc:25:21: internal compiler error: in digest_init_r, at
cp/typeck2.c:1211
   25 |   return {{B {{42}}}};
      |                     ^
0x6a3a05 digest_init_r
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/typeck2.c:1211
0x8bf6be convert_like_real
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/call.c:7131
0x8c0bf9 perform_implicit_conversion_flags(tree_node*, tree_node*, int, int)
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/call.c:11063
0xa8cfc9 convert_for_initialization(tree_node*, tree_node*, tree_node*, int,
impl_conv_rhs, tree_node*, int, int)
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/typeck.c:9167
0xa8e1b0 check_return_expr(tree_node*, bool*)
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/typeck.c:9741
0xa4734f finish_return_stmt(tree_node*)
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/semantics.c:895
0x9c5a67 cp_parser_jump_statement
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/parser.c:12854
0x9c5a67 cp_parser_statement
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/parser.c:11126
0x9c6168 cp_parser_statement_seq_opt
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/parser.c:11592
0x9c6248 cp_parser_compound_statement
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/parser.c:11546
0x9de2c5 cp_parser_function_body
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/parser.c:22562
0x9de2c5 cp_parser_ctor_initializer_opt_and_function_body
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/parser.c:22599
0x9deb4b cp_parser_function_definition_after_declarator
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/parser.c:27666
0x9df899 cp_parser_function_definition_from_specifiers_and_declarator
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/parser.c:27582
0x9df899 cp_parser_init_declarator
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/parser.c:20205
0x9c2a52 cp_parser_simple_declaration
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/parser.c:13476
0x9e5880 cp_parser_declaration
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/parser.c:13173
0x9e5ffc cp_parser_translation_unit
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/parser.c:4698
0x9e5ffc c_parse_file()
        /home/krnowak/projects/gcc/trunk/build/../src/gcc/cp/parser.c:41039
0xaec1bb c_common_parse_file()
       
/home/krnowak/projects/gcc/trunk/build/../src/gcc/c-family/c-opts.c:1155
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reply via email to