Opened 7 years ago
Closed 6 years ago
#12123 closed Bugs (fixed)
Using Boost.Signals2 with Boost.Variant leads to compilation error, MSVC 14 (suspected compiler bug)
Reported by: | Owned by: | Frank Mori Hess | |
---|---|---|---|
Milestone: | To Be Determined | Component: | signals2 |
Version: | Boost 1.60.0 | Severity: | Problem |
Keywords: | Cc: | gmarcano@…, raad@… |
Description
Attempting to compile a program that has a signal with a function type taking a variant as a parameter (e.g. boost::signals2::signal<void(const boost::variant<int>)>), and then calling said signal after it has been connected to something leads to a compilation failure for MSVC 14, Visual Studio 2015 Update 2. The actual error is rather long, but has to do with the compiler failing to disambiguate the type of the argument related to variants. I will be attaching a reduced version of the program that causes the compilation failure on MSVC 14 and also the error log I get.
This program is compiled correctly on GCC 5.3, which is why I think this is a compiler bug. I've already filed a bug report/ticket with Microsoft just in case. Could this be worked around in any way?
Attachments (2)
Change History (8)
by , 7 years ago
by , 7 years ago
Attachment: | Source.cpp added |
---|
comment:1 by , 7 years ago
After more troubleshooting today, I am unsure whether the problem lies within Boost.Signals2 or Boost.Variant. I was able to reproduce the problem with just Boost.Variant in my project, but I was unable to reproduce it without Boost.Signals2 in a reduced test case. This seems to hint that the problem lies more with Boost.Variant, although I will leave the component as Boost.Signals2 until someone with more knowledge can determine that.
While doing more reading and testing, could this issue be related to the infamous MSVC extension allowing for temporary variables to bind to non-const references? I am able to compile the program in MSVC by using this extension (making parameters be non-const references).
comment:2 by , 7 years ago
Cc: | added |
---|
The problem is boost::variant's unconstrained templated constructor, which cannot be used in C++17's std::tuple.
There are two related boost::varant bug reports: https://svn.boost.org/trac/boost/ticket/5871 https://svn.boost.org/trac/boost/ticket/11602
The problem mentioned in a Visual C++ blog post: https://blogs.msdn.microsoft.com/vcblog/2016/04/14/stl-fixes-in-vs-2015-update-2/
comment:3 by , 7 years ago
boost::any seems to have the same unconstrained template constructor, see my problem report https://svn.boost.org/trac/boost/ticket/12110.
As a possible workarround I may suggest you to to #define BOOST_NO_CXX11_HDR_TUPLE
comment:4 by , 7 years ago
This patch seems to have fixed the similar issue reported in #12110 :
https://github.com/boostorg/signals2/commit/db0d3f55cccb2dbd8ab88a146af9100f2fca740b
comment:5 by , 7 years ago
I can confirm this fixes the problem with boost::variant for me. Thanks a lot!
comment:6 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Changes merged to master, was fixed for 1.61 release.
Reduced sample code illustrating code that fails to compile