https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116422
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Clang rejects it too: ``` <source>:7:37: error: no viable overloaded '=' 7 | const_cast<domain &>(d) = other.d; | ~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~ <source>:7:37: note: type 'domain' (aka 'ring<int>') is incomplete 7 | const_cast<domain &>(d) = other.d; | ~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~ ``` TO workaround the broken code for GCC 15+, you can use -Wno-error=template-body . But the code is definitely broken because there is no viable `operator =` since domain (aka ring<int>) is non-dependent type and is incomplete at the time you try to use `operator =`.