[Development] Proposal: Deprecating platforms in Qt 5.6 that don't support lambda

Thiago Macieira thiago.macieira at intel.com
Fri Feb 20 17:05:23 CET 2015

On Friday 20 February 2015 09:51:59 Marc Mutz wrote:
> Just make sure - and that's a big part of what I was trying to refer to -
> that  you don't use that statment in more than one function. Because
> identical lambdas in different functions have different types, and thus
> templates they are passed to are instantiated anew each time. And compilers
> don't merge identical executable code from different template
> instantiations (or do they)?

I don't think they can, unless they're running in LTO mode.

They need to assume that you compare function pointers and thus each function 
needs a different entry point, even if they have the same code. The best you 
can expect is a different entry point that has an unconditional branch to the 
common code.

> Cf. the commits that confine QStringLiteral to static inline functions to
> avoid  duplicating the QString array data for each use in a different
> function.

The compiler needs to make the same assumption here.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

More information about the Development mailing list