[Boost-bugs] [Boost C++ Libraries] #2409: boost::optional (boost-1.36.0) fails to compile on MSVS 9.0 with struct member alignment being set to 1 byte

Subject: [Boost-bugs] [Boost C++ Libraries] #2409: boost::optional (boost-1.36.0) fails to compile on MSVS 9.0 with struct member alignment being set to 1 byte
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-10-13 12:10:49


#2409: boost::optional (boost-1.36.0) fails to compile on MSVS 9.0 with struct
member alignment being set to 1 byte
----------------------------------+-----------------------------------------
 Reporter: slava_at_[hidden] | Owner: fcacciola
     Type: Bugs | Status: new
Milestone: Boost 1.37.0 | Component: optional
  Version: Boost 1.36.0 | Severity: Regression
 Keywords: |
----------------------------------+-----------------------------------------
 When I try to compile the following code with MSVS 9.0 and boost-1.36.0
 with struct member alignment being set to 1 or 2 bytes, it fails with
 boost::STATIC_ASSERTION_FAILURE:
 {{{
 #include <boost/optional.hpp>

 boost::optional<int> test_func(int i) {
         if(i) return boost::optional<int>(1234);
         else return boost::optional<int>();
 }


 int main(int argc, char* argv[])
 {
         test_func(1);
         return 0;
 }
 }}}

 The errors are:
 {{{
 d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(206)
 : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'
 1> with
 1> [
 1> x=false
 1> ]
 1>
 d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(218)
 : see reference to class template instantiation
 'boost::detail::type_with_alignment_imp<Align>' being compiled
 1> with
 1> [
 1> Align=4
 1> ]
 1>
 d:\users\slava\etap\external\boost\boost\optional\optional.hpp(112) : see
 reference to class template instantiation
 'boost::type_with_alignment<Align>' being compiled
 1> with
 1> [
 1> Align=4
 1> ]
 1>
 d:\users\slava\etap\external\boost\boost\optional\optional.hpp(113) : see
 reference to class template instantiation
 'boost::optional_detail::aligned_storage<T>::dummy_u' being compiled
 1> with
 1> [
 1> T=int
 1> ]
 1>
 d:\users\slava\etap\external\boost\boost\optional\optional.hpp(448) : see
 reference to class template instantiation
 'boost::optional_detail::aligned_storage<T>' being compiled
 1> with
 1> [
 1> T=int
 1> ]
 1>
 d:\users\slava\etap\external\boost\boost\optional\optional.hpp(455) : see
 reference to class template instantiation
 'boost::optional_detail::optional_base<T>' being compiled
 1> with
 1> [
 1> T=int
 1> ]
 1> d:\users\slava\test\test.cpp(8) : see reference to class
 template instantiation 'boost::optional<T>' being compiled
 1> with
 1> [
 1> T=int
 1> ]
 1>d:\users\slava\etap\external\boost\boost\type_traits\type_with_alignment.hpp(207)
 : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'
 1> with
 1> [
 1> x=false
 1> ]
 }}}

 Setting struct member alignment to 4 or more bytes solves the problem. The
 same code compiles well with any alignment value with boost-1.35.

-- 
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2409>
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:49:58 UTC