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

            Bug ID: 92804
           Summary: [10 Regression] ICE trying to use concept as a
                    nested-name-specifier
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
            Blocks: 67491
  Target Milestone: ---

template<typename T>
concept foo = true;

template<typename T>
void bar(T t)
{
  if constexpr (foo<T>::value)
  {
  }
}

int main()
{
  bar(1);
}


Compiled with -std=gnu++2a on trunk:

iced.cc: In function 'void bar(T)':
iced.cc:7:22: internal compiler error: in cp_parser_nested_name_specifier_opt,
at cp/parser.c:6467
    7 |   if constexpr (foo<T>::value)
      |                      ^
0x9edca7 cp_parser_nested_name_specifier_opt
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:6467
0x9ea58b cp_parser_simple_type_specifier
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:17994
0x9d8ee0 cp_parser_type_specifier
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:17652
0x9d9ea6 cp_parser_decl_specifier_seq
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:14249
0x9f6e6f cp_parser_condition
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:12128
0x9dce0e cp_parser_selection_statement
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:11883
0x9dce0e cp_parser_statement
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:11258
0x9de1f2 cp_parser_statement_seq_opt
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:11742
0x9de2c8 cp_parser_compound_statement
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:11696
0x9f6755 cp_parser_function_body
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:22867
0x9f6755 cp_parser_ctor_initializer_opt_and_function_body
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:22918
0x9f9a91 cp_parser_function_definition_after_declarator
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:28675
0x9fa831 cp_parser_function_definition_from_specifiers_and_declarator
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:28591
0x9fa831 cp_parser_init_declarator
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:20496
0x9ff004 cp_parser_single_declaration
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:29166
0x9ff171 cp_parser_template_declaration_after_parameters
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:28738
0x9ffc89 cp_parser_explicit_template_declaration
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:29004
0x9ffc89 cp_parser_template_declaration_after_export
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:29023
0xa02999 cp_parser_declaration
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:13271
0xa02fe7 cp_parser_translation_unit
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:4721
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.


With -std=gnu++17 -fconcepts on gcc-9-branch we get an inaccurate error (it's
not a variable template) but no ICE:

iced.cc: In function 'void bar(T)':
iced.cc:7:17: error: variable template-id 'foo<T>' in nested-name-specifier
    7 |   if constexpr (foo<T>::value)
      |                 ^~~~~~
iced.cc:2:9: note: 'template<class T> concept const bool foo<T>' declared here
    2 | concept foo = true;
      |         ^~~
iced.cc:7:30: error: expected initializer before ')' token
    7 |   if constexpr (foo<T>::value)
      |                              ^
iced.cc:7:30: error: the value of 'value' is not usable in a constant
expression
iced.cc: In instantiation of 'void bar(T) [with T = int]':
iced.cc:14:8:   required from here
iced.cc:7:3: error: the value of 'value' is not usable in a constant expression
    7 |   if constexpr (foo<T>::value)
      |   ^~
iced.cc:5:12: warning: unused parameter 't' [-Wunused-parameter]
    5 | void bar(T t)
      |          ~~^


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67491
[Bug 67491] [meta-bug] concepts issues

Reply via email to