[Development] Compiler bug in Clang 3.4 with precompiled header with QueuedConnection

Jędrzej Nowacki jedrzej.nowacki at digia.com
Tue Jul 22 08:50:26 CEST 2014


On Monday 21 of July 2014 23:12:04 Olivier Goffart wrote:
> Hi,
> 
> I just debugged a quite weird bug with QueuedConnection and foinction
> pointer base connection.
> 
> There is a compiler bug in clang 3.4 with precompiled header.
> Normally, a static variable within a template should have a different
> address for different template parameters .
> In other words:
> template<typename T> int *foo() { static int i; return &i; }
> so foo<int>() != foo<double>()
> 
> However, if foo is in a precompiled header, this is not the case.
> 
> And this breaks the detection of the QMetaType for the QueuedConnection
> since we rely on static variables different for each types.
> http://code.woboq.org/qt5/qtbase/src/corelib/kernel/qobject_impl.h.html#105
> 
> As a result, Qt believe the metatypes are not what they are, resulting in
> wrong type conversions, and weird crash when the event is received.
> 
> The bug is fixed in Clang 3.5. (not released yet)
> I don't know if it was present in earlier version of clang.
> 
> Should precompiled header be disabled by default for this compiler version?

Hi,

Yes. I'm not totally sure, but I think we may have more places that depends on 
the correct behavior. Nice catch!

Cheers,
  Jędrek



More information about the Development mailing list