https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65985
Bug ID: 65985 Summary: compiler segfault with assert() in constexpr constructor body Product: gcc Version: 5.1.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rhalbersma at gmail dot com Target Milestone: --- The following code segfaults with -std=c++1y for g++ 5.1.0 and trunk 20150502 on the combination of constexpr and assert() in the constructor body (removing either the constexpr keyword everywhere or the assert() will compile cleanly). #include <cassert> class Angle { int degrees = 0; constexpr auto invariant() const noexcept { return 0 <= degrees && degrees < 360; } public: explicit constexpr Angle(int n) noexcept : degrees{n % 360} { assert(invariant()); } /* implicit */ constexpr operator auto() const noexcept { return degrees; } }; int main() { static_assert(Angle{360} == 0, ""); } This code correctly compiles with -std=c++14 from Clang 3.3 and higher.