Ticket #3395: zd

File zd, 1.5 KB (added by Ralf W. Grosse-Kunstleve, 12 years ago)

proposed patch for review

Line 
1Index: optional.hpp
2===================================================================
3--- optional.hpp (revision 67097)
4+++ optional.hpp (working copy)
5@@ -103,6 +103,12 @@
6
7 namespace optional_detail {
8
9+#if defined(__GNUC__) \
10+ && !(__GNUC__ == 3 && __GNUC_MINOR__ == 2) \
11+ && !defined(__INTEL_COMPILER)
12+#define BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS
13+#endif
14+
15 // This local class is used instead of that in "aligned_storage.hpp"
16 // because I've found the 'official' class to ICE BCB5.5
17 // when some types are used with optional<>
18@@ -112,8 +118,8 @@
19 {
20 // Borland ICEs if unnamed unions are used for this!
21 union
22-#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
23 // This works around GCC warnings about breaking strict aliasing rules when casting storage address to T*
24+#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
25 __attribute__((may_alias))
26 #endif
27 dummy_u
28@@ -125,7 +131,7 @@
29
30 public:
31
32-#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
33+#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
34 void const* address() const { return &dummy_; }
35 void * address() { return &dummy_; }
36 #else
37@@ -437,7 +443,7 @@
38 private :
39
40 // internal_type can be either T or reference_content<T>
41-#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
42+#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
43 // This workaround is supposed to silence GCC warnings about broken strict aliasing rules
44 internal_type const* get_object() const
45 {