constexpr icon indicating copy to clipboard operation
constexpr copied to clipboard

Compilation with GCC < 9.0

Open philippefoubert opened this issue 5 years ago • 0 comments

With GCC < 9.0, the bug 67371 - Never executed "throw" in constexpr function fails to compile gives errors.

It has been solved for GCC >= 9.0 with 86678 - constexpr evaluation incorrectly diagnoses unevaluated call to non-constexpr function.

A workaround is to add in "cx_math.h":

// GCC
//  Bug 67371 - Never executed "throw" in constexpr function fails to compile
//  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86678
//  Fixed for GCC 9.
#if defined(__GNUC__) && (__GNUC__ < 9)
#  define BUG_67371
#endif

and modify the constexpr long double floor(long double x) and constexpr long double ceil(long double x) functions the following way:

[...]
#ifndef BUG_67371
  throw err::ceil_runtime_error();
#endif  // BUG_67371
[...]

philippefoubert avatar Jan 06 '20 15:01 philippefoubert