[Boost-bugs] [Boost C++ Libraries] #13076: Compilation error on MSVC2015+ on base_from_member used in a class with __declspec(dllexport)

Subject: [Boost-bugs] [Boost C++ Libraries] #13076: Compilation error on MSVC2015+ on base_from_member used in a class with __declspec(dllexport)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-06-15 15:54:17


#13076: Compilation error on MSVC2015+ on base_from_member used in a class with
__declspec(dllexport)
------------------------------+---------------------------
 Reporter: mwu <mwu-tow@…> | Owner: no-maintainer
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: utility
  Version: Boost 1.64.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------
 Consider the following code:

 {{{
 //#define BOOST_NO_CXX11_VARIADIC_TEMPLATES

 #include <boost/utility/base_from_member.hpp>

 class __declspec(dllexport) Foo : public boost::base_from_member<int>
 {
 public:
 };
 }}}

 It fails to compile with the following error:
 {{{
 example.cpp
 /opt/compiler-
 explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(135): error
 C2061: syntax error: identifier 'T'
 /opt/compiler-
 explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(135): note:
 This diagnostic occurred in the compiler generated function
 'boost::base_from_member<int,0>::base_from_member(T &&...)
 noexcept(<expr>)'
 /opt/compiler-
 explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(136): error
 C2056: illegal expression
 /opt/compiler-
 explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(136): note:
 This diagnostic occurred in the compiler generated function
 'boost::base_from_member<int,0>::base_from_member(T &&...)
 noexcept(<expr>)'
 /opt/compiler-
 explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(135): error
 C2660: 'operator new': function does not take 2 arguments
 /opt/compiler-
 explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(135): note:
 while compiling class template member function
 'boost::base_from_member<int,0>::base_from_member<,void>(void)
 noexcept(<expr>)'
 /opt/compiler-
 explorer/libs/boost_1_64_0\boost/utility/base_from_member.hpp(135): error
 C2056: illegal expression
 Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25017 for x64
 Copyright (C) Microsoft Corporation. All rights reserved.
 Compiler exited with result code 2
 }}}

 See https://godbolt.org/g/CqFg8t

 If I add the `BOOST_NO_CXX11_VARIADIC_TEMPLATES` define, the issue goes
 away. The issue affects both MSVC 2015 and MSVC 2017.

 Even if the underlying cause is the compiler error (to be checked), the
 issue should at least be prevented by proper compiler version detection.

 This affects other boost libraries relying on base_from_member, like
 Boost.Iostreams.

--
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13076>
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-06-15 15:58:12 UTC