diff --git a/include/boost/optional/detail/optional_aligned_storage.hpp b/include/boost/optional/detail/optional_aligned_storage.hpp index 6c7d581..4093885 100644 --- a/include/boost/optional/detail/optional_aligned_storage.hpp +++ b/include/boost/optional/detail/optional_aligned_storage.hpp @@ -25,12 +25,8 @@ template class aligned_storage { // Borland ICEs if unnamed unions are used for this! - union - // This works around GCC warnings about breaking strict aliasing rules when casting storage address to T* -#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS) - __attribute__((__may_alias__)) -#endif - dummy_u + // BOOST_MAY_ALIAS works around GCC warnings about breaking strict aliasing rules when casting storage address to T* + union BOOST_MAY_ALIAS dummy_u { char data[ sizeof(T) ]; BOOST_DEDUCED_TYPENAME type_with_alignment< diff --git a/include/boost/optional/detail/optional_config.hpp b/include/boost/optional/detail/optional_config.hpp index e26d73c..deabd21 100644 --- a/include/boost/optional/detail/optional_config.hpp +++ b/include/boost/optional/detail/optional_config.hpp @@ -44,11 +44,11 @@ # define BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION #endif -#if defined(__GNUC__) && !defined(__INTEL_COMPILER) -// GCC since 3.3 has may_alias attribute that helps to alleviate optimizer issues with -// regard to violation of the strict aliasing rules. The optional< T > storage type is marked -// with this attribute in order to let the compiler know that it will alias objects of type T -// and silence compilation warnings. +#if !defined(BOOST_NO_MAY_ALIAS) +// GCC since 3.3 and some other compilers have may_alias attribute that helps to alleviate +// optimizer issues with regard to violation of the strict aliasing rules. The optional< T > +// storage type is marked with this attribute in order to let the compiler know that it will +// alias objects of type T and silence compilation warnings. # define BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS #endif