5 ms·
Reply (to myself, based on a correction) Apologises, I mis-remembered the rule -- it is only C++ types which have a non-trivial destructor which cause an abort
by CJefferson 10y ago
Reply (to myself, based on a correction)
Apologises, I mis-remembered the rule -- it is only C++ types which have a non-trivial destructor which cause an abort when you pass them to a variadic funciton.
HOWEVER. This is still undefined behaviour. nullptr is an object of type std::nullptr_t. When you pass it to execlp, it just gets pushed through as a bit-pattern (as with any type passed to a variadic C function), and there is no guarantee what comes out looks like a "true" (void*)0 C-style null pointer.
- ben0x539 10y agoThere isn't a guarantee that NULL has a bit pattern that's the same as a true (void)0 C-style null pointer either. I didn't look it up directly but apparently NULL is allowed to be nullptr instead of 0, and nullptr converts to void in varargs arguments. I think C/C++ also allow actual null pointers to have different bit patterns than the integer zero, so in C++03 passing NULL to terminate a varargs argument list would technically be incorrect, or maybe implementation-defined.
- CJefferson 10y agoDamn, there is a special exception in the definition of vararg functions, just for nullptr! throws things in the air I give up having discussions about C++.
- ben0x539 10y agoI give up too, because the HN formatting is actively fighting me.