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

Olivier Goffart olivier at woboq.com
Tue Oct 22 16:56:55 CEST 2013


On Tuesday 22 October 2013 15:44:00 Simon Hausmann wrote:
> On Tuesday 22. October 2013 15.35.24 Tobias Hunger wrote:
> > On 22.10.2013 15:31, Nicolás Alvarez wrote:
> > > I don't think the standard is relevant here. The C++ standard doesn't
> > > and can't say anything about whether 'break' and 'continue' are allowed
> > > in a statement expression inside the 'for' header, because statement
> > > expressions don't exist in the standard to begin with; they are a gcc
> > > extension. Clang has to reverse engineer the exact semantics from gcc
> > > behavior.
> > 
> > So can we avoid relying on GCC extensions here?
> > 
> > I doubt that we can ask clang to be 100% compatible with GCC anyway and
> > making that a requirement for Qt to function properly is not what we
> > should aim for IMHO.
> 
> The code in question is behind "#if defined(Q_CC_GNU)", so as long as clang
> triggers that it has to be compatible with gcc's extensions.
> 
> If it turns out that this isn't possible - i.e. they choose not to be
> compatible in this case, then we need to use the slower fall-back code that
> exists.

Interrestingly, back while clang was still beta and tried to get up to speed 
with gcc, there was a similar problem in which clang miscompiled that break. 
http://llvm.org/bugs/show_bug.cgi?id=7189
This was quickly fixed, and compatibility with GCC in that extention.

This is probably just a temporary bug of clang's trunk, and I beleive the gcc 
behaviour will be restored.


Now with C++11, we don't need the extension and we can morph the foreach into 
a range based for:

// return a const copy of the container
template<typename T> const T qForeachHelper(const T &c) { return c; }

#define foreach(variable, container)  for(variable : qForeachHelper(container))

I think this should have the same semantic as currently

If clang decide not to restore the gcc behaviour, then we can still fallback 
to the slightly slower generic implementation in the #else when not compiling 
with c++11  (I did not manage to get rid of the warning with the __extension__ 
keyword)

-- 
Olivier

Woboq - Qt services and support - http://woboq.com - http://code.woboq.org



More information about the Development mailing list