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

            Bug ID: 122559
           Summary: ICE in lookup_name(tree_node*, LOOK_where, LOOK_want)
                    since gcc 15.1
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mario.rodriguezb1 at um dot es
  Target Milestone: ---

## Program

```

enum class Type : bool {
    army, enemy
};
template <typename F>
Type type(F&& get_random) {
    if (auto [value = get_random()]) {
        return Type::enemy;
    } else return Type::army;
}
int main() {
    auto _ = type(Type::army);

}
```

## Stack dump

```
<source>:7:5: internal compiler error: Segmentation fault
    7 |     if (auto [value = get_random()]) {
      |     ^~
0x2903958 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x28f874b internal_error(char const*, ...)
        ???:0
0xcd1390 lookup_name(tree_node*, LOOK_where, LOOK_want)
        ???:0
0xda7acd instantiate_decl(tree_node*, bool, bool)
        ???:0
0xdb156a instantiate_pending_templates(int)
        ???:0
0xc26778 c_parse_final_cleanups()
        ???:0
0xeb6768 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```

## To quickly reproduce:

https://godbolt.org/z/G98Pe6rPW

Reply via email to