[config] C++0X Compiler doesn't support classes with constructors in unions

Hi, is there a macro that can be tested to know if a compiler doesn't support classes with constructors in unions? Best, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/config-C-0X-Compiler-doesn-t-support-clas... Sent from the Boost - Dev mailing list archive at Nabble.com.

On 22 February 2011 16:06, Vicente Botet <vicente.botet@wanadoo.fr> wrote:
Hi,
is there a macro that can be tested to know if a compiler doesn't support classes with constructors in unions?
What compiler(s) implement this as an extension? It isn't allowed in C++03 either: "An object of a class with a non-trivial constructor, a non-trivial copy constructor, a non-trivial destructor, or a non-trivial copy assignment operator cannot be a member of a union, nor can an array of such objects." -- Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404

Nevin Liber wrote:
On 22 February 2011 16:06, Vicente Botet <vicente.botet@wanadoo.fr> wrote:
is there a macro that can be tested to know if a compiler doesn't support classes with constructors in unions?
What compiler(s) implement this as an extension?
It isn't an extension but a feature of C++0x.
It isn't allowed in C++03 either: "An object of a class with a non-trivial constructor, a non-trivial copy constructor, a non-trivial destructor, or a non-trivial copy assignment operator cannot be a member of a union, nor can an array of such objects."
That restriction no longer applies in C++0x. _____ Rob Stewart robert.stewart@sig.com Software Engineer, Core Software using std::disclaimer; Susquehanna International Group, LLP http://www.sig.com IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

On Tue, Feb 22, 2011 at 5:06 PM, Vicente Botet <vicente.botet@wanadoo.fr>wrote:
Hi,
is there a macro that can be tested to know if a compiler doesn't support classes with constructors in unions?
No, and GCC 4.6 is supporting them. See http://gcc.gnu.org/projects/cxx0x.html The macro might be named BOOST_NO_UNRESTRICTED_UNIONS. See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf Do you have an actual need for such a macro? We only want to add macros that will be actually used by Boost libraries. If you do have a need, would you like to try your hand at providing the macro, test cases, docs, etc? --Beman

Beman Dawes wrote:
On Tue, Feb 22, 2011 at 5:06 PM, Vicente Botet <vicente.botet@wanadoo.fr>wrote:
Hi,
is there a macro that can be tested to know if a compiler doesn't support classes with constructors in unions?
No, and GCC 4.6 is supporting them. See http://gcc.gnu.org/projects/cxx0x.html
The macro might be named BOOST_NO_UNRESTRICTED_UNIONS.
See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf
Do you have an actual need for such a macro? We only want to add macros that will be actually used by Boost libraries.
I was testing your Endian library and the macro used to know if constructors shouldn't be used for the endian class is up to now # if defined(BOOST_NO_DEFAULTED_FUNCTIONS) && defined(BOOST_ENDIAN_FORCE_PODNESS) # define BOOST_ENDIAN_NO_CTORS # endif I tested with gcc 4.4/4.5.1 c++0x with BOOST_ENDIAN_FORCE_PODNESS defined and the union test fails. This should mean that for these versions BOOST_NO_DEFAULTED_FUNCTIONS is not defined so the constructors are defined. Shouldn't you use BOOST_NO_UNRESTRICTED_UNIONS instead of BOOST_NO_DEFAULTED_FUNCTIONS in this case?
If you do have a need, would you like to try your hand at providing the macro, test cases, docs, etc?
Yes, I know the process :). Unfortunately I don't have access to gcc 4.6 now (my hard drive was broken :( ), so I can not test it now. I will see once I reach to reinstall a 4.6 version on my new computer. Best, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/config-C-0X-Compiler-doesn-t-support-clas... Sent from the Boost - Dev mailing list archive at Nabble.com.

On Wed, Feb 23, 2011 at 10:48 AM, Vicente Botet <vicente.botet@wanadoo.fr>wrote:
I was testing your Endian library and the macro used to know if constructors shouldn't be used for the endian class is up to now
# if defined(BOOST_NO_DEFAULTED_FUNCTIONS) && defined(BOOST_ENDIAN_FORCE_PODNESS) # define BOOST_ENDIAN_NO_CTORS # endif
I tested with gcc 4.4/4.5.1 c++0x with BOOST_ENDIAN_FORCE_PODNESS defined and the union test fails.
This should mean that for these versions BOOST_NO_DEFAULTED_FUNCTIONS is not defined so the constructors are defined.
Shouldn't you use BOOST_NO_UNRESTRICTED_UNIONS instead of BOOST_NO_DEFAULTED_FUNCTIONS in this case?
Probably. I should revisit all of the macro use now that we have real compilers to test with. I'm tied up for the rest of this week, but will refresh endian about the middle of next week. --Beman
participants (4)
-
Beman Dawes
-
Nevin Liber
-
Stewart, Robert
-
Vicente Botet