[Bug c++/60399] constexpr ctor that does not init an attribute should be rejected but isn't
daniel.kruegler at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Mon Mar 3 18:47:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60399
Daniel Krügler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler@googlemail.
| |com
--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
No, the compiler is conforming: According to 7.1.6 p6:
"If the instantiated template specialization of a constexpr [..] member
function of a class template would fail to satisfy the requirements for a
constexpr function or constexpr constructor, that specialization is still a
constexpr function or constexpr constructor, even though a call to such a
function
cannot appear in a constant expression."
So, per se, the situation is well-defined here and there is fundamentally
nothing wrong with the constructor, because your code does not attempt to use
it in a constant expression.
What makes your code ill-formed is the fact that your template could never be
instantiated to make the constructor a constexpr constructor, see the following
sentence:
"If no specialization of the template would satisfy the requirements for
a constexpr function or constexpr constructor when considered as a non-template
function or constructor, the template is ill-formed; no diagnostic required."
As you may notice, this kind of code does not require a diagnostics.
More information about the Gcc-bugs
mailing list