Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67109 - trunk/boost/optional
From: rwgk_at_[hidden]
Date: 2010-12-08 12:53:30


Author: rwgk
Date: 2010-12-08 12:53:29 EST (Wed, 08 Dec 2010)
New Revision: 67109
URL: http://svn.boost.org/trac/boost/changeset/67109

Log:
boost/optional/optional.hpp: avoid gcc 3.2 warnings
Text files modified:
   trunk/boost/optional/optional.hpp | 12 +++++++++---
   1 files changed, 9 insertions(+), 3 deletions(-)

Modified: trunk/boost/optional/optional.hpp
==============================================================================
--- trunk/boost/optional/optional.hpp (original)
+++ trunk/boost/optional/optional.hpp 2010-12-08 12:53:29 EST (Wed, 08 Dec 2010)
@@ -103,6 +103,12 @@
 
 namespace optional_detail {
 
+#if defined(__GNUC__) \
+ && !(__GNUC__ == 3 && __GNUC_MINOR__ == 2) \
+ && !defined(__INTEL_COMPILER)
+#define BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS
+#endif
+
 // This local class is used instead of that in "aligned_storage.hpp"
 // because I've found the 'official' class to ICE BCB5.5
 // when some types are used with optional<>
@@ -112,8 +118,8 @@
 {
     // Borland ICEs if unnamed unions are used for this!
     union
-#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
     // 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
@@ -125,7 +131,7 @@
 
   public:
 
-#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
     void const* address() const { return &dummy_; }
     void * address() { return &dummy_; }
 #else
@@ -437,7 +443,7 @@
   private :
 
     // internal_type can be either T or reference_content<T>
-#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
     // This workaround is supposed to silence GCC warnings about broken strict aliasing rules
     internal_type const* get_object() const
     {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk