[Development] Clang (trunk) no longer builds Qt applications

Keith Gardner kreios4004 at gmail.com
Tue Oct 22 15:22:45 CEST 2013


On Tue, Oct 22, 2013 at 8:15 AM, Tobias Hunger <tobias.hunger at digia.com>wrote:

> Hello,
>
> I just noticed that clang from trunk is no longer able to build Qt
> applications. This is due to a change which makes clang consider "break"
> statements outside of a loop body or switch statement illegal.
>
> Unfortunately this triggers on each Q_FOREACH/foreach used by Qt
> applications!
>
>
> The following code:
>
> QList<QObject *> m_components << obj1 << obj2;
> foreach (QObject *component, m_components) {
>      ...
> }
>
> will get expanded to:
>
>
> for (QForeachContainer<__typeof__(m_components)>
> _container_(m_components); !_container_.brk && _container_.i !=
> _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; }))
> for (QObject *component = *_container_.i;; __extension__
> ({--_container_.brk; break;})) {
>      ...
> }
>
> which Clang now considers an error and will produce the following message
>
>
> .... error: 'break' statement not in loop or switch statement body
>
>
> stopping the build.
>
>
>
> Apparently that is exactly what the C++ standard requires. Based on my
> limited understanding of the details of the standard the condition in
> the for statement is not part of the loop body. Is there somebody with a
> deeper knowledge of the standard that can provide some insights here?
>
>
>
> http://llvm.org/viewvc/llvm-project?view=revision&revision=193073 is the
> relevant change that introduced this diagnosis into clang.
>
> http://llvm.org/bugs/show_bug.cgi?id=17650 is the bug I just filed with
> Clang, making them aware that they broke the build of basically all Qt
> applications out there. The commit massage states that gcc rejects the
> code -- which is wrong as I can build QtC fine using gcc.
>
> I hope the clang project will consider to disable this patch (or at
> least have a switch to turn it off again).
>
> But IMHO we need to address this in Qt, too.
>
> Best Regards,
> Tobias
>
>
Couldn't Q_FOREACH/foreach use the range based for loops if the compiler
supports it?  This way, there is no C++ trickery to enable the feature.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131022/792270fa/attachment.html>


More information about the Development mailing list