Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error introduced by boost::core::launder #122

Closed
alandefreitas opened this issue Jan 3, 2024 · 13 comments
Closed

Error introduced by boost::core::launder #122

alandefreitas opened this issue Jan 3, 2024 · 13 comments

Comments

@alandefreitas
Copy link
Member

alandefreitas commented Jan 3, 2024

The Boost.URL drone job for Windows (x86) broke in the last days from an old run to a more recent run. These two jobs are testing the very same commit: no code changes in Boost.URL. Also, it only fails in MSVC 14.1. MSVC 14.3 works fine.

Output
c:\drone\boost-root\libs\url\src\detail\pattern.cpp(700) : fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'd:\agent\_work\2\s\src\vctools\compiler\utc\src\p2\main.c', line 187)
 To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++ 
 Help menu, or open the Technical Support help file for more information

c:\drone\boost-root\libs\url\src\detail\pattern.cpp(700) : fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'd:\agent\_work\2\s\src\vctools\compiler\utc\src\common\error.c', line 835)
 To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++ 
 Help menu, or open the Technical Support help file for more information

    call "bin.v2\standalone\msvc\msvc-14.1\adrs-mdl-32\archt-x86\msvc-setup.bat"  >nul
 cl /Zm800 -nologo "libs\url\src\detail\pattern.cpp" -c -Fo"bin.v2\libs\url\test\limits\limits.test\msvc-14.1\rls\adrs-mdl-32\cxstd-17-iso\thrd-mlt\detail\pattern.obj"     -TP /wd4675 /EHs /std:c++17 /GR /Zc:throwingNew /O2 /Ob2 /W4 /WX /MD /Zc:forScope /Zc:wchar_t /Zc:inline /Gw /we4265 -DBOOST_ALL_NO_LIB=1 -DBOOST_URL_DYN_LINK=1 -DBOOST_URL_MAX_SIZE=16 -DBOOST_URL_NO_LIB -DBOOST_URL_STATIC_LINK -DNDEBUG "-I." "-Ilibs\url\extra" "-Ilibs\url\test\limits" 

...failed compile-c-c++ bin.v2\libs\url\test\limits\limits.test\msvc-14.1\rls\adrs-mdl-32\cxstd-17-iso\thrd-mlt\detail\pattern.obj...

The message is very unhelpful but Peter helped me track down the error. We have a pattern.cpp source file that includes Boost.Optional and the error goes away when we check out any version of Boost.Optional before e31cf6f. In particular, the error goes away if we comment out:

    T const& ref() const { return * /*boost::core::launder*/(ptr_ref()); }
    T &      ref()       { return * /*boost::core::launder*/(ptr_ref()); }

Unfortunately, I can't identify why this is causing an error. We could only identify what is causing it.

This is also related to #121.

@akrzemi1
Copy link
Member

akrzemi1 commented Jan 3, 2024

That's unfortunate.
The only thing I can do is to revert #119.

@alandefreitas
Copy link
Member Author

Yes. I wish we knew why this is causing an error. We just know what is causing it.

@akrzemi1
Copy link
Member

akrzemi1 commented Jan 3, 2024

This should be fixed now by 8375df7.

@alandefreitas
Copy link
Member Author

Windows x86 is working now: https://drone.cpp.al/boostorg/url/2329/11/2

Thanks!

@pdimov
Copy link
Member

pdimov commented Jan 4, 2024

It's better to use BOOST_WORKAROUND(BOOST_MSVC, < 1920) here because msvc-14.2 and above have no problems with launder and unversioned ifdefs aren't a good practice.

But it might be even better to apply this workaround in core/launder.hpp instead.

@akrzemi1
Copy link
Member

akrzemi1 commented Jan 4, 2024

I just wonder if this is a problem with launder or with a combination of factors.

@pdimov
Copy link
Member

pdimov commented Jan 4, 2024

It's a compiler bug in VS2017 (32 bit); an internal compiler error with toolset=msvc-14.1 cxxstd=17 variant=release address-model=32.

@akrzemi1
Copy link
Member

akrzemi1 commented Jan 4, 2024

I mean, have other problems std::launder been reported on this setup, other than the Optional use case? If not, it will be safer to fix it only in Optional.

@alandefreitas
Copy link
Member Author

I think we only caught this bug in Boost.URL, but I think Christian has been using launder all around to eliminate -Wmaybe-uninitialized errors. I think this bug is being propagated to other libraries. Still, the only reason we're not catching this bug in more libraries is that most people are not testing this rather unusual combination of factors.

@pdimov
Copy link
Member

pdimov commented Jan 4, 2024

No, but std::launder hasn't seen much use. I think it's fairly safe to say that using it under MSVC 14.1 is likely to run into errors with more complex expressions, and there's probably no upside because the compiler probably doesn't need it.

@pdimov
Copy link
Member

pdimov commented Jan 4, 2024

Right, not many are testing msvc-14.1 in 32 bit mode.

@pdimov
Copy link
Member

pdimov commented Jan 4, 2024

boostorg/core@e4adc76 should make the workaround here unnecessary.

@akrzemi1
Copy link
Member

akrzemi1 commented Jan 4, 2024

Thanks. I have reverted the fix in Optional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants