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

            Bug ID: 69637
           Summary: ICE on an invalid bit-field with template name for
                    width
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

I ran into the following ICE when I accidentally put the ", 3" just past the
template argument list (instead of typing "foo<int, 3>()"):

  template <class T, int N>
  constexpr int foo () { return N; }

  struct B { unsigned c: foo<int>, 3(); };

The problem can be further reduced to the following (invalid) test case.  All
supported versions of GCC fail similarly.

$ cat t.c && /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -S -Wall -Wextra
-Wpedantic -std=c++11 -xc++ t.c
template <class T>
int foo () { return 1; }

struct B {
    unsigned c: foo;
};
t.c:5:17: error: width of bit-field ‘c’ has non-integral type ‘<unresolved
overloaded function type>’
     unsigned c: foo;
                 ^~~
t.c:5:17: internal compiler error: unexpected expression ‘foo’ of kind overload
0xaab7c1 cxx_eval_constant_expression
        /src/gcc/trunk/gcc/cp/constexpr.c:3815
0xaabb75 cxx_eval_outermost_constant_expr
        /src/gcc/trunk/gcc/cp/constexpr.c:3870
0xaac23b cxx_constant_value(tree_node*, tree_node*)
        /src/gcc/trunk/gcc/cp/constexpr.c:3957
0x8c76c5 check_bitfield_decl
        /src/gcc/trunk/gcc/cp/class.c:3439
0x8c9c3d check_field_decls
        /src/gcc/trunk/gcc/cp/class.c:3818
0x8d55c8 check_bases_and_members
        /src/gcc/trunk/gcc/cp/class.c:5738
0x8db8d8 finish_struct_1(tree_node*)
        /src/gcc/trunk/gcc/cp/class.c:6887
0x8ddb0e finish_struct(tree_node*, tree_node*)
        /src/gcc/trunk/gcc/cp/class.c:7201
0x943814 cp_parser_class_specifier_1
        /src/gcc/trunk/gcc/cp/parser.c:21290
0x9444f9 cp_parser_class_specifier
        /src/gcc/trunk/gcc/cp/parser.c:21518
0x938d3e cp_parser_type_specifier
        /src/gcc/trunk/gcc/cp/parser.c:15817
0x933904 cp_parser_decl_specifier_seq
        /src/gcc/trunk/gcc/cp/parser.c:12738
0x932e73 cp_parser_simple_declaration
        /src/gcc/trunk/gcc/cp/parser.c:12281
0x932dfb cp_parser_block_declaration
        /src/gcc/trunk/gcc/cp/parser.c:12228
0x932b6e cp_parser_declaration
        /src/gcc/trunk/gcc/cp/parser.c:12125
0x9326a2 cp_parser_declaration_seq_opt
        /src/gcc/trunk/gcc/cp/parser.c:12004
0x921e73 cp_parser_translation_unit
        /src/gcc/trunk/gcc/cp/parser.c:4321
0x971d71 c_parse_file()
        /src/gcc/trunk/gcc/cp/parser.c:37357
0xb2f3dd c_common_parse_file()
        /src/gcc/trunk/gcc/c-family/c-opts.c:1064
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

Reply via email to