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

            Bug ID: 127818
           Summary: constant expression error from usage of string literal
                    in templated contexts
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: irvsrc at gmail dot com
  Target Milestone: ---

Example:
```
auto constexpr fn(auto...) {
    auto constexpr v = true ? "a" : "b"; // error
}

auto main() -> int {
    fn();
}
```

Output:
```
<source>: In instantiation of 'constexpr auto fn(auto:1 ...) [with auto:1 =
{}]':
<source>:5:7:   required from here
    5 |     fn();
      |     ~~^~
<source>:2:20: error: '(const char*)"a"' is not a constant expression
    2 |     auto constexpr v = true ? "a" : "b"; // error
      |                    ^
```

Notes:
- The error occurs across all GCC and C++ versions from what I have tested.
- The error occurs in all templates (e.g variable templates, class templates,
templated lambdas).

GCC (trunk)
-std=c++26

Reply via email to