[Development] QtCore missing check for memory allocation

Thiago Macieira thiago.macieira at intel.com
Tue Mar 10 17:40:05 CET 2015


On Tuesday 10 March 2015 08:18:42 Koehne Kai wrote:
> > Except that dynamically linked Windows Qt applications (read: most) don't
> > work this way, so Windows users are left out in the cold. DLLs do not
> > allow
> > you to simply replace one new operator across link boundaries. See the
> > comments in this Qt bug:
> > https://bugreports.qt.io/browse/QTBUG-37395
> 
> True.
[cut]
> Question is whether you can easily force all Qt modules to use a custom
> operator new / delete ... I've seen suggestions [1] to define an inline
> operator new / delete (e.g. in qglobal.h), but that seems to violate the
> standard explicitly stating that "The program's definitions shall not be
> specified as inline " (C++14 17.6.4.3.3 3). Might nevertheless work though,
> since there's a high chance that qglobal.h is included in all places where
> Qt allocates/deallocates memory...

Note that we're talking about a standard violation in the first place. The 
standard says you can replace operator new, so if MSVC doesn't allow you to do 
it properly, then you can throw the standard out of the window. If an inline 
operator new (for MSVC only) solved the problem, it would be ok.

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




More information about the Development mailing list