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

            Bug ID: 118447
           Summary: Local scope constant is not permitted as function's
                    default argument
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

This program:
```
void f(int) {}

int main() {
    constexpr static int c = 1;
    void f(int = c);
    f();
}
```
is accepted in Clang and MSVC, but GCC complains:
> error: local variable 'c' may not appear in this context

Online demo: https://gcc.godbolt.org/z/5dqbxv9sd

Related discussion: https://stackoverflow.com/q/79350640/7325599

Reply via email to