This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/60399] constexpr ctor that does not init an attribute should be rejected but isn't
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 03 Mar 2014 18:47:34 +0000
- Subject: [Bug c++/60399] constexpr ctor that does not init an attribute should be rejected but isn't
- Auto-submitted: auto-generated
- References: <bug-60399-4 at http dot gcc dot gnu dot org/bugzilla/>
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.