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

Marshall Clow mclow.lists at gmail.com
Wed Apr 29 16:31:24 UTC 2015


On Fri, Apr 24, 2015 at 8:08 AM, Richard Smith <richardsmith at google.com>
wrote:

> On 23 April 2015 at 19:51, Dennis Handly <dhandly at cup.hp.com> wrote:
>
>> >From: Richard Smith <richardsmith at google.com>
>> >but does not appear to place any requirements on
>> alignof(decltype(nullptr)).
>> >Itanium C++ ABI differ: Clang and EDG use alignof(void*). GCC uses 1.
>>
>> Was this intentional or just an oversight, confusing the alignment of the
>> pointer vs what it points to?
>>
>> >alignof(void*) seems like a better answer to me. Thoughts?
>>
>> Yes, all pointers should be aligned the same.  Unless there is short vs
>> far, types.
>>
>
> Well, nullptr_t is not a pointer. There's really no need for us to make it
> have the same size and alignment as any particular pointer type, but if we
> choose to do so it makes sense to be consistent.
>
>
nullptr_t may not be a pointer type, but everyone thinks of it as one.
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 *))

-- Marshall
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20150429/c01a36d1/attachment.html>


More information about the cxx-abi-dev mailing list