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

Compilation fails with GCC 5.5 on Ubuntu 16.04 #477

Open
maximilianriemensberger opened this issue Aug 13, 2019 · 4 comments
Open

Compilation fails with GCC 5.5 on Ubuntu 16.04 #477

maximilianriemensberger opened this issue Aug 13, 2019 · 4 comments

Comments

@maximilianriemensberger
Copy link
Contributor

GCC 5.5 (e.g. Ubuntu 16.04) complains about this line calling into a non-constexpr function

h -= hours{12};

external/date/include/date/date.h: In function 'constexpr std::chrono::hours date::make12(std::chrono::hours)':
external/date/include/date/date.h:3920:15: error: call to non-constexpr function 'std::chrono::duration<_Rep, _Period>& std::chrono::duration<_Rep, _Period>::operator-=(const std::chrono::duration<_Rep, _Period>&) [with _Rep = long int; _Period = std::ratio<3600l>]'
             h -= hours{12};
               ^
external/date/include/date/date.h: In function 'constexpr std::chrono::hours date::make24(std::chrono::hours, bool)':
external/date/include/date/date.h:3934:15: error: call to non-constexpr function 'std::chrono::duration<_Rep, _Period>& std::chrono::duration<_Rep, _Period>::operator+=(const std::chrono::duration<_Rep, _Period>&) [with _Rep = long int; _Period = std::ratio<3600l>]'
             h += hours{12};
               ^
@maximilianriemensberger
Copy link
Contributor Author

Replacing the two failing lines with h = h - hours{12} and h = h + hours{12} fixes it for me.

@HowardHinnant
Copy link
Owner

gcc-5.5 did not fully implement the C++14 constexpr rules in <chrono>.

@maximilianriemensberger
Copy link
Contributor Author

An alternative to the proposed solution would be to conditionally macro away the constexpr from those functions which are already conditionally constexpr. Would you be open to any of those fixes?

@HowardHinnant
Copy link
Owner

Yes. I haven't decided on the best way forward yet. Your PR is one good way. Dialing back on when CONSTCD14 gets set to constexpr for gcc (based on gcc version) is another.

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

2 participants