[PATCH] D45015: [Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.
Akira Hatanaka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 1 16:12:31 PDT 2018
ahatanak added a comment.
I think clang should error out or warn when aligned operator or builtin operator new/delete functions are used when they are not available (r306722 should have handled them).
I'm also not sure not defining `__cpp_aligned_new` is sufficient. My understanding is that if `__cpp_aligned_new` is not defined, libc++ will define `_LIBCPP_HAS_NO_ALIGNED_ALLOCATION`, which will cause the aligned new/delete functions declared in <new> to be removed. That is fine if the new/delete function that is used in a program is one of the function implicitly declared by the compiler (e.g., 'void operator delete ( void*, std::align_val_t)'), but if it isn't one of those functions (e.g., 'void operator delete (void *, std::align_val_t, const std::nothrow_t&)'), clang will produce diagnostics that are not very informative to the user (error: no matching function for call to 'operator delete') instead of the one added in r306722 (aligned allocation function of type is only available on ...).
For example:
#include <new>
void foo1(void *p, std::align_val_t a, std::nothrow_t t) {
operator delete(p, a, t);
}
Repository:
rC Clang
https://reviews.llvm.org/D45015
More information about the cfe-commits
mailing list