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

            Bug ID: 97011
           Summary: ICE on C++ 20 code: gcc_assert failure in DWARF
                    generation (tree_add_const_value_attribute, at
                    dwarf2out.c:20283)
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dimitri.gorokhovik at free dot fr
  Target Milestone: ---

a) This code:

template <unsigned> struct posit {};
template <typename T> concept Posit = true; 
template <auto T> concept Posit_Term = true;

template <auto ...> struct s
{
        template <Posit_Term
#if BUG
                  at
#endif
                  > struct ss {};
        constexpr auto at (Posit pos) const { return ss <pos> {}; };
};

constexpr auto t = s <> {}.at (posit <0> {});


when compiled as follows:
g++ -c -std=c++2a -fconcepts-ts -g3 bug-1.cpp -DBUG=1

provokes the internal compiler error:
bug-1.cpp:15:45: internal compiler error: in tree_add_const_value_attribute, at
dwarf2out.c:20283
   15 | constexpr auto t = s <> {}.at (posit <0> {});
      |                                             ^
0x701df1 tree_add_const_value_attribute
        ../../src/gcc/dwarf2out.c:20283
0xc5fbc1 gen_remaining_tmpl_value_param_die_attribute
        ../../src/gcc/dwarf2out.c:27130
0xc6ec58 gen_remaining_tmpl_value_param_die_attribute
        ../../src/gcc/dwarf2out.c:27116
0xc6ec58 dwarf2out_early_finish
        ../../src/gcc/dwarf2out.c:32076
0xbce88a symbol_table::finalize_compilation_unit()
        ../../src/gcc/cgraphunit.c:3012
Please submit a full bug report,

Defining 'BUG' and compiling with '-g3' are necessary conditions for
reproduction.

B) Indently (BUG undefined), the same code, compiled with '-W -Wall -Wextra'
added, gives the warning

bug-1.cpp: In instantiation of ‘constexpr auto s<elts>::at(auto:1) const [with
auto:1 = posit<0>; auto ...elts = {}]’:
bug-1.cpp:15:44:   required from here
bug-1.cpp:12:34: warning: parameter ‘pos’ set but not used
[-Wunused-but-set-parameter]
   12 |         constexpr auto at (Posit pos) const { return ss <pos> {}; };
      |                            ~~~~~~^~~

which doesn't seem correct.

gcc version:
g++ (GCC) 11.0.0 20200910 (experimental)

Reply via email to