Using nullptr instead of Q_NULLPTR

Michael Pyne mpyne at kde.org
Sat Aug 15 21:32:51 BST 2015


On Fri, August 14, 2015 22:49:44 Thomas L├╝bking wrote:
> On Freitag, 14. August 2015 22:34:28 CEST, Thiago Macieira wrote:
> > Don't do that. If you use nullptr, there's no going back to
> > zero because it's
> > not the same. You've irrevocably locked yourself into requiring a compiler
> > that supports it.
> 
> Even if it's only been used in a 0x0 "compliant" way?
> Some ABI trap?

A source compat trap perhaps. nullptr is unequivocally a *pointer*, and names 
the null pointer for whatever pointer type it's cast to. 0 can be a pointer or 
an integer, so code that previously 'worked' using nullptr might become 
ambiguous (or worse, change behavior) if switched to 0.

In fact there was a JuK bug with gstreamer many years ago where 64-bit JuK 
would crash because passing NULL as a sentinel to a gstreamer varargs function 
was turned into passing 0, which C++ treated as an (32-bit) int instead of a 
pointer due to its use as a varargs argument. This wouldn't have happened if 
nullptr had been used.

Regards,
 - Michael Pyne




More information about the kde-core-devel mailing list