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

            Bug ID: 116567
           Summary: Display "Compiler internal error" when using default
                    non-type template parameter.
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: polarlinda6 at 163 dot com
  Target Milestone: ---

```cpp
template<auto, auto = [] {}>
bool flag = true;

template<typename>
struct core {
  template<typename>
  auto func() -> bool {
    return flag<0>;
  }
};

auto main() -> int {
  core<int> _;
  [[maybe_unused]] bool flag = _.func<int>();
}
```


error message:
<source>: In instantiation of 'bool core< <template-parameter-1-1> >::func()
[with <template-parameter-2-1> = int; <template-parameter-1-1> = int]':
<source>:15:43:   required from here
   15 |   [[maybe_unused]] bool flag = _.func<int>();
      |                                ~~~~~~~~~~~^~
<source>:2:23: internal compiler error: in tsubst, at cp/pt.cc:16442
    2 | template<auto, auto = [] {}>
      |                       ^~~~~
0x2031cbc internal_error(char const*, ...)
        ???:0
0x77895f fancy_abort(char const*, int, char const*)
        ???:0
0x939840 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x944481 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x93cea7 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x93247f instantiate_decl(tree_node*, bool, bool)
        ???:0
0x94df63 instantiate_pending_templates(int)
        ???:0
0x8355a8 c_parse_final_cleanups()
        ???:0
0xa0d1e8 c_common_parse_file()
        ???:0

Additional Information:
Version: x86-64 gcc 14.2.1
command-line parameter: -std=c++20
Link: https://godbolt.org/z/9sTTcT4Mo

PS: The code compiles successfully on msvc and clang.

Reply via email to