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

Stephen Chu stephen at ju-ju.com
Sat Jul 7 17:17:58 CEST 2012


On 7/7/12 4:57 AM, Thiago Macieira wrote:
> On sábado, 7 de julho de 2012 09.36.55, Olivier Goffart wrote:
>> On Saturday 07 July 2012 07:33:56 Thiago Macieira wrote:
>>> On sábado, 7 de julho de 2012 02.12.42, Olivier Goffart wrote:
>>>> Anyway, if we want to support that version of clang, this still need to
>>>> be
>>>> worked around, so I suggest that the problematic code should be #ifdef'd
>>>> out  for the 'broken' versions of clang.
>>>
>>> We also need to know which version fixes the bug so we can apply a correct
>>> version fix. And the Apple clang version and how to figure out when it is
>>> Apple clang.
>>>
>>> For now, I'd say we blacklist constexpr in Clang.
>>
>> This has nothing to do with constexpr
>> It is the aggregate initialisation that has a small bug.
>
> I understand that. But the constructors only exist because we have constexpr.
> If we didn't have it, we wouldn't have added the constructors which would have
> left them as PODs.

There is a separate constexpr issue in QFlag class. QUrlTwoFlags in 
qurl.h has this constructor:

     Q_DECL_CONSTEXPR inline QUrlTwoFlags(QFlag f) : i(f) {}

Clang complains that:

/Qt/5.0/qtbase/include/QtCore/../../src/corelib/io/qurl.h:70:48: error: 
constexpr constructor's 1st parameter type 'QFlag' is not a literal type
     Q_DECL_CONSTEXPR inline QUrlTwoFlags(QFlag f) : i(f) {}
                                          ~~~~~~^
/Qt/5.0/qtbase/include/QtCore/../../src/corelib/global/qflags.h:51:7: 
note: 'QFlag' is not literal because it is not an aggregate and has no 
constexpr constructors other than copy or move constructors
class QFlag
       ^

Adding Q_DECL_CONSTEXPR to QFlag constructor fixes it:

     Q_DECL_CONSTEXPR inline QFlag(int i);

I don't know if if is another Clang bug.



More information about the Development mailing list