jeudi 22 décembre 2016

g++ internal compiler error segmentation fault with recursive constexpr

I recently updated my g++ version to 6.3.0 (g++ (Homebrew GCC 6.3.0) 6.3.0), but now i get g++: internal compiler error: Segmentation fault: 11 (program cc1plus). With the previous version (I'm not completely sure but around) 5.2 everything worked. An one of my other computers I use g++ (Ubuntu 5.2.1-22ubuntu2) 5.2.1 and that also works.

The code is:

constexpr bool checkForPrimeNumber(const int p, const int t)
{
    return p <= t or (p % t and checkForPrimeNumber(p, t + 2));
}

constexpr bool checkForPrimeNumber(const int p)
{
    return p == 2 or (p & 1 and checkForPrimeNumber(p, 3));
}

int main() 
{
    static_assert(checkForPrimeNumber(65521), "bug...");
}

I compile the code with

g++ test.cpp -std=c++11 -fconstexpr-depth=65535

What can i possibly do to work around this?

Aucun commentaire:

Enregistrer un commentaire