Presumably the C++ liaison people considered compatibility as part of the
WG14 discussions.  In any case, I see no sign that (beyond the
"fundamental type" terminology issue) the wording in C++ is any better
thought out than the pre-DR#445 C wording.

The C++ wording matches the pre-DR 445 C wording and says that
max_align_t is the most strictly aligned type supported.  DR 445
changes max_align_t to be the most strictly aligned basic type.
This change has potential ABI compatibility implications (in C
now, in C++ in the future).

The C change isn't a problem for C++ [yet] because there "the
most strictly aligned type in all contexts (storage durations)"
is constrained by C++ allocated storage which, unlike in C, is
limited to malloc() and operator new (tere's no aligned_alloc()
in C++ yet).  But unless the next C++ adopts an analogous
wording change as C, since the next revision of C+++ will very
likely adopt aligned_alloc(), C++ implementations will be able
to (even encouraged to) define max_align_t to reflect a more
restrictive alignment than DR 445 allows C.  Implementations
that do will be incompatible with C.

C90 and C99 compatibility requires malloc to return memory suitably
aligned for all types definable within C90 and C99, and it would be very
confusing to say in C11 that certain header typedefs are within such a
rule but others (such as max_align_t) aren't because they are new in C11
(a rule saying that all standard header types can be stored in memory
returned by malloc is much better for the C11 user).

I disagree.  I don't think there's any risk of confusion, and
I also don't think that having max_align_t reflect the alignment
of the most strictly aligned basic type (which is easy to obtain
via _Alignof) without providing a way to determine the greatest
supported alignment is helpful.

But this is a discussion that would be best continued on the WG14
list.  Here I'd like to get my updated patch reviewed so that I
can move on to my other GCC 6 tasks.

Thanks
Martin

Reply via email to