https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107945
Brian Bi <bbi5291 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bbi5291 at gmail dot com
--- Comment #5 from Brian Bi <bbi5291 at gmail dot com> ---
In the first case, I think GCC's behaviour can be argued to be correct.
[temp.inst]/3.1 says that when you implicitly instantiate a class template, you
only instantiate the declarations of static data members, not their
definitions. Which means that until you do something that provokes the
instantiation of the *definition* of `C<incomplete>::t`, the compiler must
treat it as a variable of type `const incomplete` that is
declared-but-not-defined, which means that you haven't yet actually attempted
to define a variable with incomplete type, which means the program is
well-formed.
In the most recent example given by Jason Liam we can reduce it to:
template <class T>
struct S {
constexpr static S s = {};
};
int main() {
auto s = S<int>::s;
}
This may be related to bug 70820, which was closed as INVALID. I think perhaps
that decision should be revisited; while I can see the argument for the above
code being well-formed, I think the interpretation of the standard being taken
in this case is wrong.