https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87544

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I can make these changes to libstdc++, but why is the compiler warning anyway?

It says:

In function ‘T* my_allocator<T>::allocate(std::size_t, const void*) [with T =
int]’,
    inlined from ‘void std::vector<_Tp,
_Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator, _Args&& ...)
[with _Args = {int}; _Tp = int; _Alloc = my_allocator<int>]’ at
/usr/include/c++/7/bits/alloc_traits.h:301:32:
alloc_limit.cpp:18:11: warning: argument 1 value ‘18446744073709551612’ exceeds
maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
     void *result = std::malloc(size);
           ^~~~~~
In file included from /usr/include/c++/7/cstdlib:75:0,
                 from alloc_limit.cpp:1:
/usr/include/stdlib.h: In member function ‘void std::vector<_Tp,
_Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator, _Args&& ...)
[with _Args = {int}; _Tp = int; _Alloc = my_allocator<int>]’:
/usr/include/stdlib.h:424:14: note: in a call to allocation function ‘void*
malloc(size_t)’ declared here
 extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;

But this is nonsense, the value is 1*sizeof(cplx) which is 8.

Why does it think we're calling it with max_size()?

Reply via email to