https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102734
Bug ID: 102734
Summary: Autodeduced method return type is available before the
class is complete
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
I believe, this program must be ill-formed:
```
class A {
static constexpr auto GetInt() noexcept { return 6; }
template<int N = GetInt()>
int func() { return N; }
};
```
because auto-deduced type of GetInt() method is used in the default template
argument, where the class is not yet complete (so method bodies are not yet
inspected).
Both Clang and MSVC reject this program, demo:
https://gcc.godbolt.org/z/3e6o8f5sz
Related discussion with slightly different example:
https://stackoverflow.com/q/56969739/7325599