[cxx-abi-dev] What is alignof(decltype(nullptr))?

Marc Glisse marc.glisse at inria.fr
Sat May 2 08:28:59 UTC 2015


On Wed, 29 Apr 2015, Marshall Clow wrote:

> nullptr_t may not be a pointer type, but everyone thinks of it as one.

Please don't over-generalize. Some people (an undefined, non-empty set), 
see it as an empty, placeholder type. It is useful as syntactic sugar, but 
any space it uses at runtime is wasted. Filling it with 0 (as at least 
clang and gcc do) is also a waste of time. (then again, gcc doesn't handle 
empty types any better, but at least clang does)

> I would go with the "principle of least astonishment" here, and say that it
> should be aligned like a pointer.
> (Especially since sizeof(nullptr_t) == sizeof(void *))

Sure, once sizeof is based on void*, alignof should be too for 
consistency, and we might as well write a 0 in there for binary 
compatibility with a function taking a void*...

-- 
Marc Glisse


More information about the cxx-abi-dev mailing list