Returning in C++14 constexpr constructor leads to ICE

Asked by Valentin Ochs on 2017-08-12

Trying to compile a class with a constexpr constructor that returns at any point like in [1] leads to the error

    foo.cpp:8:3: in constexpr expansion of 'mwi.A::A()'
    foo.cpp:8:3: internal compiler error: in cxx_eval_constant_expression, at cp/constexpr.c:4201
     A mwi;
       ^~~

On godbolt.org I can see that it works for ARM64-gcc and x86_64-gcc, but not ARM-gcc, so it's not just on my box.

Should I file a bug report?

Some data:
Release 6-2017-q2-update, binary package, x86-64 host.

Cheers,
Valentin

[1] https://p.0au.de/b086020b/foo.cpp

Question information

Language:
English Edit question
Status:
Open
For:
GNU ARM Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
2017-08-13
Last reply:
2017-08-13
Thomas Preud'homme (robotux) said : #1

Confirmed when using just arm-none-eabi-gcc -c. Adding -std=c11 on the command-line gives an error instead. Were the x86 and Aarch64 GCC compiler you used in your test also GCC 6?

Best regards.

Thomas Preud'homme (robotux) said : #2

I can reproduce with trunk GCC by adding -std=c++14 on the command-line.

Valentin Ochs (cation) said : #3

That's curious, with GCC 6.3.0 on goldbolt.org it works with x64 and arm64, and on a local (x64) gcc 7.1.0 it also works.

Valentin Ochs (cation) said : #4

That is: Yes, the x86 and aarch64 compilers were also gcc 6. :)

Can you help with this problem?

Provide an answer of your own, or ask Valentin Ochs for more information if necessary.

To post a message you must log in.