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

--- Comment #6 from Ivan Lazaric <ivan.lazaric.gcc at gmail dot com> ---
I applied your patch locally, consider the following example:
```cpp
#include <source_location>
#include <format>

consteval bool check(std::source_location loc) {
  __builtin_constexpr_diag(0, "", std::format("line: {}", loc.line()));
  __builtin_constexpr_diag(0, "", std::format("func: {}",
loc.function_name()));
  return true;
}

template<auto B = check(std::source_location::current())>
void fn1() {}

int main() {
  fn1();

  auto lambda = []<auto B = check(std::source_location::current())> {};
  lambda();
}
```

Compiler output (modulo constexpr backtraces):
```
constexpr message: line: 10
constexpr message: func: 
constexpr message: line: 16
constexpr message: func: 
```

It seems to do the right thing for `fn1()` 
(though I personally would find `{14, "int main()"}` behaviour more useful).
The last line, function name from the source location in lambda template
default argument,
should probably be `int main()`

Reply via email to