[PATCH] D73245: Don't define std::max_align_t if not used in C++03 mode
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 30 17:46:47 PST 2020
rsmith added a comment.
libc++ intentionally provides all the C++11 library functionality that it can, even when used from C++03 mode. So on the face of it, providing this name in C++03 mode seems appropriate.
However... the implementation currently used by libc++ **doesn't work** in that mode: the various compilers' `<stddef.h>`s will not provide `::max_align_t` when included in C++03 mode. So either this fails to build (on NetBSD, which provides its own <stddef.h>, which I think is the issue that Joerg is reporting), or -- worse -- it silently uses the wrong definition for `max_align_t` by falling through to the `long double` fallback (which is what happens everywhere other than NetBSD). So I think we should do //something// here; the current approach is broken in (at least) C++03 mode.
But I think this is not the right fix. We should remove the `long double` fallback instead. We have no reason to think that this is correct in the cases where it's reachable (if any exist), and libc++ shouldn't be making arbitrary guesses about ABI decisions like this. Either we have the right `::max_align_t` from `<stddef.h>` or we just can't provide one. And we should fix the `defined(__NetBSD__)` check to properly check for whatever conditions NetBSD defines `max_align_t` (maybe there's nothing better than `(defined(__NetBSD__) && __cplusplus >= 201103L)`, but someone could look at their `<stddef.h>` to find out).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73245/new/
https://reviews.llvm.org/D73245
More information about the cfe-commits
mailing list