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

MSVC Warning: error C4127: conditional expression is constant #727

Closed
vschoech opened this issue Jun 17, 2020 · 4 comments · Fixed by #730
Closed

MSVC Warning: error C4127: conditional expression is constant #727

vschoech opened this issue Jun 17, 2020 · 4 comments · Fixed by #730
Labels
Milestone

Comments

@vschoech
Copy link

Compiling with boost 1.73.0, MSVC 2017 Version 15.8.0 with compiler options /W4 and /std:c++latest, I get "conditional expression is constant" in two places:

\boost_1_73_0\boost\geometry\algorithms\detail\overlay\follow.hpp(491): error C4127: conditional expression is constant
\boost_1_73_0\boost\geometry\algorithms\detail\overlay\follow.hpp(491): note: consider using 'if constexpr' statement instead
\boost_1_73_0\boost\geometry\algorithms\detail\overlay\intersection_insert.hpp(390): note: see reference to function template instantiation 'OutputIterator boost::geometry::detail::overlay::follow<GeometryOut,LineString,Areal,boost::geometry::overlay_difference,false,false>::apply<std::deque<turn_info,std::allocator<_Ty>>,OutputIterator,RobustPolicy,Strategy>(const LineString &,const Polygon &,boost::geometry::detail::overlay::operation_type,Turns &,const RobustPolicy &,OutputIterator,const Strategy &)' being compiled

and

\boost_1_73_0\boost\geometry\algorithms\detail\overlay\follow.hpp(523): error C4127: conditional expression is constant
\boost_1_73_0\boost\geometry\algorithms\detail\overlay\follow.hpp(523): note: consider using 'if constexpr' statement instead
@mloskot
Copy link
Member

mloskot commented Jun 18, 2020

error C4127: conditional expression is constant

Before the codebase switches to C++17, I'm afraid, there is no cleaner way to get rid of this warning than #pragma warning(disable:4127)

@tinko92
Copy link
Contributor

tinko92 commented Jun 19, 2020

Just for consideration: If the FollowIsolatedPoints is the only problem here, something like the following might not be too intrusive:

constexpr_if_macro.patch.txt

(TL;DR: the patch splits the condition and uses the BOOST_IF_CONSTEXPR macro for the constant expression)

I admit that it is not very pretty, but it should get rid of the warning if I understand correctly (I don't have the proprietary software that was mentioned in the issue, so I can't test it myself). The other option I see would involve partial template specialization but that would probably require at least 10 lines of boilerplate, so that couldn't be considered clean either.

@awulkiew
Copy link
Member

@vschoech
Copy link
Author

I can confirm that this warning no longer occurs with 1.75.0. Thank you!

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

Successfully merging a pull request may close this issue.

4 participants