#if __cpp_aligned_new
_GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
_GLIBCXX_TXN_SAFE
- __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
+ __attribute__((__externally_visible__, __alloc_size__ (1), __alloc_align__ (2), __malloc__));
_GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
_GLIBCXX_TXN_SAFE
_GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
_GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
_GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
_GLIBCXX_TXN_SAFE
- __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
+ __attribute__((__externally_visible__, __alloc_size__ (1), __alloc_align__ (2), __malloc__));
_GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
_GLIBCXX_TXN_SAFE
- _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
+ _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __alloc_align__ (2), __malloc__));
void operator delete[](void*, std::align_val_t) _GLIBCXX_TXN_SAFE
_GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
void operator delete[](void*, std::align_val_t, const std::nothrow_t&)
--- /dev/null
+// { dg-options "-Wattributes" }
+// { dg-do compile { target c++17 } }
+
+#include <new>
+
+int main()
+{
+ // PR c++/86878 has a patch to make these warn.
+ (void) operator new(1, std::align_val_t(3)); // { dg-warning "power of two" "" { xfail *-*-* } }
+ (void) operator new[](1, std::align_val_t(10)); // { dg-warning "power of two" "" { xfail *-*-* } }
+ (void) operator new(1, std::align_val_t(0), std::nothrow_t()); // { dg-warning "power of two" "" { xfail *-*-* } }
+ (void) operator new[](1, std::align_val_t(-1), std::nothrow_t()); // { dg-warning "power of two" "" { xfail *-*-* } }
+}