Page 1 of 1

new: argument 1 value '18446744073709551599' exceeds maximum

Posted: Thu Sep 29, 2022 2:41 pm
by AndrewAPrice
When I compile user programs in my OS using gcc and libc++ and optimizations turned on, I get the following warning when I call 'new':

Code: Select all

../Libraries/libcxx/public/new:248:24: warning: argument 1 value '18446744073709551599' exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
  248 |   return ::operator new(__args...);
It hasn't yet caused any noticble bugs, and I the warning doesn't appear when optimizations are disabled.

I'm curious why I'm getting this warning through.
18446744073709551599 = 0xFFFFFFFFFFFFFFEF Is something trying to allocate -16 bytes?

Re: new: argument 1 value '18446744073709551599' exceeds max

Posted: Thu Sep 29, 2022 5:24 pm
by Octocontrabass
AndrewAPrice wrote:When I compile user programs in my OS using clang
Are you sure you're using Clang? That looks like a GCC warning.
AndrewAPrice wrote:Is something trying to allocate -16 bytes?
The static analyzer seems to think so. There may be a problem in your bounds checking, or (if you're actually using GCC) you might have hit a false positive.

Re: new: argument 1 value '18446744073709551599' exceeds max

Posted: Thu Sep 29, 2022 9:16 pm
by AndrewAPrice
You're right, I'm using GCC 12.2.0.