This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: constexpr vs. non-literal library types round two
- From: Jason Merrill <jason at redhat dot com>
- To: Benjamin Kosnik <bkoz at redhat dot com>
- Cc: libstdc++ at gcc dot gnu dot org, Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Date: Tue, 09 Nov 2010 22:17:22 -0600
- Subject: Re: constexpr vs. non-literal library types round two
- References: <20101109150408.5f8d2c70@shotwell>
On 11/09/2010 03:04 PM, Benjamin Kosnik wrote:
I believe that non-literal types cannot be used to create constexpr
variables if they have a non-trivial destructor.
constexpr variables must have literal type.
This is not currently specified in the standard
that I can see. If I'm wrong, can somebody help me out?
http://wiki.dinkumware.com/twiki/pub/Wg21batavia/CoreWorkingGroup/proposed_resolution_core-1125.html
This seems obvious: a non-trivial destructor means that the object has
to be registered for destruction. No compiler magic allowed! Ipso
Facto, no constexpr construction is allowed.
We can still statically initialize objects of non-literal (and
non-const) types via constexpr constructors.
So, the language changes that I would expect to see would be:
1) 3.9 p 10, literal type: remove the first point, ie:
â a trivial copy constructor,
This is issue 1198 in
http://wiki.dinkumware.com/twiki/pub/Wg21batavia/CoreWorkingGroup/constexpr-misc.html
2) 5.19 p 2, constant expressions: add
--- expressions that use or call non-literal class types with
user-defined (and not defaulted) destructors.
See 1125, above.
Jason