[Development] Using Qt 5 with C++11/Clang 3.1?

Stephen Chu stephen at ju-ju.com
Fri Jul 6 23:26:13 CEST 2012


On 7/6/12 3:23 PM, Thiago Macieira wrote:
> On sexta-feira, 6 de julho de 2012 14.53.56, Stephen Chu wrote:
>> I tried Clang 3.1 and it compiles with or without the equal sign.
>
> Then I don't understand. If it supports brace-initialisation for non-PODs, why
> is it complaining about QBasicAtomicInt?

I took the preprocessor output of one of the moc_*.cpp files and find 
that it comes down to something like this:

struct A {
	int a;
	A(int value) : a(value) {}
};

struct S {
	A a;
};

S s { { -1 } }; // error
A a { -1 }; // OK
A aa( -1 ); // OK

Error with Clang 3.1:

error: initialization of non-aggregate type 'A' with an initializer list
S s { { -1 } };
       ^~~~~~

It seems the added constructor is confusing Clang. The same code 
compiles fine with GCC 4.7.

In Qt 5's case. A is QBasicAtomicInt and S is QtPrivate::RefCount. If 
that makes sense.



More information about the Development mailing list