[Development] Clang (trunk) no longer builds Qt applications
Tobias Hunger
tobias.hunger at digia.com
Tue Oct 22 15:15:03 CEST 2013
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
--
Tobias Hunger, Senior Software Engineer - Digia, Qt
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Anja Wasenius
Sitz der Gesellschaft: Berlin. USt-IdNr: DE 286 306 868
Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
More information about the Development
mailing list