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

Stephen Chu stephen at ju-ju.com
Fri Jul 6 20:53:56 CEST 2012


On 7/6/12 2:25 PM, Thiago Macieira wrote:
> On sexta-feira, 6 de julho de 2012 13.22.38, Stephen Chu wrote:
>> On 7/6/12 12:19 PM, Thiago Macieira wrote:
>>> On sexta-feira, 6 de julho de 2012 18.12.10, Olivier Goffart wrote:
>>>> #if defined(Q_COMPILER_CONSTEXPR) && defined(Q_COMPILER_DEFAULT_MEMBERS)
>>>> &&
>>>> defined(Q_COMPILER_DELETE_MEMBERS)
>>>>
>>>> fixes the problem for me.
>>>> So it should be disabled for those broken version of clang.
>>>
>>> Looks like a compiler bug for me, or we forgot one Q_COMPILER macro. We
>>> might
>> So this error is caused by bugs in Clang 3.1?
>
> I don't know. I need someone who has the compiler to test that it's
> implementing the features correctly.
>
>>> need to introduce Q_COMPILER_UNIFORM_INITIALIZATION.
>>
>> Isn't that Q_COMPILER_INITIALIZER_LISTS?
>
> No.
>
> Uniform initialisation is like this:
>
> struct Foo
> {
> 	Foo(int, const char *);
> };
>
> Foo f = { 1, "hello" };
>
>
> ICC:
> Line 6: error: initialization with "{...}" is not allowed for object of type
> "Foo"
>    Foo f = { 1, "hello" };
>            ^
>
> Clang 3.0:
> <stdin>:6:5: error: non-aggregate type 'Foo' cannot be initialized with an
> initializer list
> Foo f = { 1, "hello" };
>      ^   ~~~~~~~~~~~~~~
>
> If I remove the equal sign, GCC still compiles and Clang produces the same
> error message, but ICC says:
> Line 6: error: no default constructor exists for class "Foo"
>    Foo f { 1, "hello" };
>        ^
>
> Line 6: error: expected a ";"
>    Foo f { 1, "hello" };
>          ^
>
> So Clang seems to support the feature partially, but will not call the
> constructor.
>

Thanks for the explanation. I got confused, again. :)

I tried Clang 3.1 and it compiles with or without the equal sign.




More information about the Development mailing list