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

Work around GCC5 compiling error in cuboid_rectangle.h (another approach to #42464) #44598

Merged
merged 1 commit into from
Oct 5, 2020

Conversation

Qrox
Copy link
Contributor

@Qrox Qrox commented Oct 4, 2020

Summary

SUMMARY: Build "Work around gcc 5 compiling error in cuboid_rectangle.h"

Purpose of change

In gcc 5, when clamp is called with explicit template argument int, clamp in cuboid_rectangle.h conflicts with clamp in cata_utility.h and a static_assert error is displayed. According to SFINAE, clamp in cuboid_rectangle.h should be discarded, which is also the behavior of all other compilers. #42464 fixed it by casting arguments instead of using explicit template argument, but it made code more verbose just for the sake of a particularly old compiler.

Describe the solution

Revert #42464 and work around the compiling error by checking for parent class / class member's existence in the template parameter list. Unfortunately this means that the classes in cuboid_rectangle.h cannot be foward declared.

Describe alternatives you've considered

Dump gcc 5.3 support?

Testing

I used compiler explorer to test this change and it seemed to work with every major compiler. It still displays a static_assert message when it should, instead of displaying some obscure template error message.

@Qrox Qrox marked this pull request as draft October 4, 2020 04:41
@Qrox Qrox force-pushed the gcc5-static-assert branch from 3057b7d to 0cfcb12 Compare October 4, 2020 12:41
@Qrox Qrox changed the title Workaround GCC5 SFINAE bug when a template class contains static_assert (another approach to #42464) Work around GCC5 compiling error in cuboid_rectangle.h (another approach to #42464) Oct 4, 2020
@Qrox Qrox force-pushed the gcc5-static-assert branch from 0cfcb12 to f3a8ad2 Compare October 4, 2020 13:39
@Qrox Qrox force-pushed the gcc5-static-assert branch from f3a8ad2 to bdf95d4 Compare October 4, 2020 15:59
@Qrox
Copy link
Contributor Author

Qrox commented Oct 5, 2020

It is working now. Travis mingw-w64 fails on tests in units_test.cpp which is unrelated, LGTM fails when building the master branch because There is not enough space on the disk, so that's probably an error in LGTM itself.

@Qrox Qrox marked this pull request as ready for review October 5, 2020 02:08
@ZhilkinSerg ZhilkinSerg merged commit 1b1e61d into CleverRaven:master Oct 5, 2020
@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments labels Oct 5, 2020
@Qrox Qrox deleted the gcc5-static-assert branch October 8, 2020 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants