João Afonso João Afonso - 2 months ago 18
C++ Question

clang compiles this snippet in Coliru, but not in Compiler Explorer. Why?

struct A{
constexpr A(){}

A a;

int main(){}

See live examples: Coliru and Compiler explorer.


You used the following compile options in coliru, while not in compiler explorer:

-std=c++1z -O2 -Wall -pedantic -fno-elide-constructors -pthread

Because your code uses constexpr, the important part here is -std=c++1z to enable modern C++ support (C++17 to be precise; note that -std=c++11 to enable C++11 is enough here).