https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105957
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-06-14
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Testcase:
#include <memory>
constexpr auto f()
{
std::allocator<long long> a;
auto n = std::size_t(-1) / (sizeof(long long) - 1);
auto p = a.allocate(n);
a.deallocate(p, n);
return n;
}
static_assert( f() );
In practice if the arithmetic wraps around and a smaller buffer is allocated,
any attempt to write beyond the allocated size would be detected in constant
evaluation anyway. So you'd still get a compilation error in most cases.