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

            Bug ID: 93689
           Summary: ICE with default argument in lambda used as non type
                    template argument
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: malle at umich dot edu
  Target Milestone: ---

This code

```
template <
    auto Z = [](int l = int(0)) -> int { return l; }
>
int f() {
    return Z();
}

int main() {
    return f();
}
```

causes this error

```
<source>: In function 'int f() [with auto Z = <lambda closure
object>main()::<lambda(int)>{}]':
<source>:5:13: internal compiler error: in gimplify_expr, at gimplify.c:12489
    5 |     return Z();
      |            ~^~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
ASM generation compiler returned: 1
```

from `g++ (Compiler-Explorer-Build) 9.2.0` compiled with these options

```
-g -o /tmp/compiler-explorer-compiler120111-1689-nlrcj.y9iua/output.s
-fdiagnostics-color=always -Wl,-rpath,/opt/compiler-explorer/gcc-9.2.0/lib
-Wl,-rpath,/opt/compiler-explorer/gcc-9.2.0/lib32
-Wl,-rpath,/opt/compiler-explorer/gcc-9.2.0/lib64 -std=c++2a
/tmp/compiler-explorer-compiler120111-1689-nlrcj.y9iua/example.cpp
```

See it on the compiler explorer: https://godbolt.org/z/TD8aHC

----

The reason I want to do this is to get source_location::current from an
operator+'s call site.  Since the operator cannot take an extra argument, I
tried template arguments and then a template argument lambda that returns a
source location.

Reply via email to