João Afonso João Afonso - 1 year ago 85
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.

Answer Source

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).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download