Re: [Boost-bugs] [Boost C++ Libraries] #7219: boost::optional<int> gives strict alias warning on GCC 4.4.6, breaks at runtime

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7219: boost::optional<int> gives strict alias warning on GCC 4.4.6, breaks at runtime
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-06-09 19:42:53


#7219: boost::optional<int> gives strict alias warning on GCC 4.4.6, breaks at
runtime
-------------------------------+-------------------------
  Reporter: Tony.Astolfi@… | Owner: fcacciola
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: optional
   Version: Boost 1.51.0 | Severity: Showstopper
Resolution: | Keywords:
-------------------------------+-------------------------
Description changed by viboes:

Old description:

> Here is my test code:
>
> #include <boost/optional.hpp>
>
> struct my_type
> {
> #if 1 // change to 0 to see the problem disappear
> typedef boost::optional<int> value_type;
> #else
> typedef boost::optional<int __attribute((__may_alias__))> value_type;
> #endif
>
> value_type value_;
>
> void set (int value)
> {
> value_ = value;
> }
>
> value_type get ()
> {
> return value_;
> }
>
> }; // class event
>
> void testCase ()
> {
> my_type a;
> a.set(4);
> bool const b = 4 == ( *a.get() );
> if( !b ) abort(); // will abort unless 'may_alias' attribute is added
> to 'int'
> }
>
> Here is my compile line:
>
> g++ -c src/thread/unittest/test_gcc_bug.cpp -o
> ../../../derived/glnxa64/obj/deployment_server/foundation/util/src/thread/unittest/test_gcc_bug.o
> -MD -MF
> ../../../derived/glnxa64/obj/deployment_server/foundation/util/src/thread/unittest/test_gcc_bug.d
> -MP -MT
> ../../../derived/glnxa64/obj/deployment_server/foundation/util/src/thread/unittest/test_gcc_bug.o
> -I../../../src/include -I../../../derived/glnxa64/src/include
> -I../include -I../../include
> -I//mathworks/hub/3rdparty/R2013a/356881/glnxa64/boost/include
> -I//mathworks/hub/3rdparty/R2013a/356141/glnxa64/cpp11compat/include
> -I//mathworks/hub/3rdparty/R2013a/356141/glnxa64/cpp11compat/include
> -I//mathworks/hub/3rdparty/R2013a/350182/glnxa64/protobuf/include
> -I//mathworks/hub/3rdparty/R2013a/350182/glnxa64/tbb/include
> -DBOOST_FILESYSTEM_VERSION=2 -DBOOST_ASIO_DISABLE_EVENTFD
> -DBOOST_ASIO_DISABLE_EPOLL -DTBB_AVAILABLE -O2 -pipe -pthread -fPIC
> -std=c++98 -fvisibility=hidden -g -D_POSIX_C_SOURCE=199506L -fno-omit-
> frame-pointer -DNDEBUG -W -Wcast-align -Wall -Wwrite-strings -Wpointer-
> arith -Wcast-qual -Wno-unused -Woverloaded-virtual -Wnon-virtual-dtor
> -Wno-ignored-qualifiers
>
> I was also able to work around it by changing the return type of certain
> optional_base<T> methods (i.e. get_impl()) to 'T
> __attribute__((__may_alias__))&' (or whatever the analogous pointer or
> reference type is).

New description:

 Here is my test code:


 {{{
 #include <boost/optional.hpp>

 struct my_type
 {
 #if 1 // change to 0 to see the problem disappear
     typedef boost::optional<int> value_type;
 #else
     typedef boost::optional<int __attribute((__may_alias__))> value_type;
 #endif

     value_type value_;

     void set (int value)
     {
         value_ = value;
     }

     value_type get ()
     {
         return value_;
     }

 }; // class event

 void testCase ()
 {
     my_type a;
     a.set(4);
     bool const b = 4 == ( *a.get() );
     if( !b ) abort(); // will abort unless 'may_alias' attribute is added
 to 'int'
 }

 }}}

 Here is my compile line:


 {{{
 g++ -c src/thread/unittest/test_gcc_bug.cpp -o
 ../../../derived/glnxa64/obj/deployment_server/foundation/util/src/thread/unittest/test_gcc_bug.o
 -MD -MF
 ../../../derived/glnxa64/obj/deployment_server/foundation/util/src/thread/unittest/test_gcc_bug.d
 -MP -MT
 ../../../derived/glnxa64/obj/deployment_server/foundation/util/src/thread/unittest/test_gcc_bug.o
 -I../../../src/include -I../../../derived/glnxa64/src/include -I../include
 -I../../include
 -I//mathworks/hub/3rdparty/R2013a/356881/glnxa64/boost/include
 -I//mathworks/hub/3rdparty/R2013a/356141/glnxa64/cpp11compat/include
 -I//mathworks/hub/3rdparty/R2013a/356141/glnxa64/cpp11compat/include
 -I//mathworks/hub/3rdparty/R2013a/350182/glnxa64/protobuf/include
 -I//mathworks/hub/3rdparty/R2013a/350182/glnxa64/tbb/include
 -DBOOST_FILESYSTEM_VERSION=2 -DBOOST_ASIO_DISABLE_EVENTFD
 -DBOOST_ASIO_DISABLE_EPOLL -DTBB_AVAILABLE -O2 -pipe -pthread -fPIC
 -std=c++98 -fvisibility=hidden -g -D_POSIX_C_SOURCE=199506L -fno-omit-
 frame-pointer -DNDEBUG -W -Wcast-align -Wall -Wwrite-strings -Wpointer-
 arith -Wcast-qual -Wno-unused -Woverloaded-virtual -Wnon-virtual-dtor
 -Wno-ignored-qualifiers
 }}}


 I was also able to work around it by changing the return type of certain
 optional_base<T> methods (i.e. get_impl()) to 'T
 __attribute__((__may_alias__))&' (or whatever the analogous pointer or
 reference type is).

--
-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7219#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC