Opened 5 years ago
Closed 5 years ago
#13393 closed Bugs (fixed)
[scope_exit] (Boost >= 1.65) VS 2015 internal compiler error in lambda
Reported by: | Tobias Loew | Owned by: | Lorenzo Caminiti |
---|---|---|---|
Milestone: | To Be Determined | Component: | scope_exit |
Version: | Boost 1.65.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Hi,
starting from Boost version 1.65 and using VS 2015 Update 3 (MSVC 19.00) the following code
int main() {
auto check_property = []() {
int test = 0; BOOST_SCOPE_EXIT(test) {
test = 42;
}BOOST_SCOPE_EXIT_END
};
return 0;
}
raises an internal compiler error: fatal error C1001: An internal error has occurred in the compiler. (compiler file 'msc1.cpp', line 1468). With earlier Boost versions it compiles fine.
I figured out that the problem is in <boost/typeof/typeof.hpp>. Since commit 12e1fe615a34c9a5e6ebe3ddf629c6491a50aa9d (DanielaE committed on Apr 14, 2017) in line 214 ff VS 2015 (w/o explicit #defines) includes <boost/typeof/decltype.hpp>. Before the commit VS 2015 included <boost/typeof/native.hpp>.
It seems that VS 2015 has problems in lambda when <boost/typeof/decltype.hpp> is included.
Unfortunately, the only way getting back the old behavior was defining BOOST_NO_CXX11_DECLTYPE or BOOST_NO_CXX11_TEMPLATE_ALIASES, but this would have major side-effects.
I would propose a new macro called BOOST_TYPEOF_MSVC_NATIVE such that when defined <boost/typeof/native.hpp> is included.
A working solution is replacing lin 18 in <boost/typeof/typeof.hpp> by
#if !defined(BOOST_TYPEOF_MSVC_NATIVE) && !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_TYPEOF_EMULATION)
Tobias
Change History (2)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
The problem was a change in Boost.Typeof. A pull request to fix it was accepted (https://github.com/boostorg/typeof/pull/11). I've also added a new test to Boost.Scope_Exit, but it isn't merged yet (https://github.com/boostorg/scope_exit/pull/5).