[Development] Warnign when building qtbase: -Walloc-size-larger-than
Lisandro Damián Nicanor Pérez Meyer
perezmeyer at gmail.com
Tue Feb 7 00:15:36 CET 2023
On Mon, 6 Feb 2023 at 19:28, Thiago Macieira <thiago.macieira at intel.com> wrote:
>
> On Monday, 6 February 2023 11:37:07 PST Thiago Macieira wrote:
> > On Monday, 6 February 2023 11:21:13 PST Lisandro Damián Nicanor Pérez Meyer
[snip]
> > No. It's a false positive. The value that GCC is reporting is also
> > impossible:
> >
> > size_t nSpans = numBuckets >> SpanConstants::SpanShift;
> > spans = new Span[nSpans];
> >
> > numBuckets is a size_t, so shifting it right will shift 7 (SpanShift) zeroes
> > in. That means the maximum value that nSpans could assume is 2^(64-7) - 1.
> >
> > If you multiply that value by sizeof(Span) == 144, that would overflow the
> > size_t though.
>
> Actually, maxNumBuckets is wrong, allowing bucketsForCapacity to overflow. But
> in practice this will only affect you after the QHash has grown to more than
> half the virtual memory size (which can only happen on 32-bit systems today).
>
> Working on a fix right now. Will push soon.
Thanks!
--
Lisandro Damián Nicanor Pérez Meyer
https://perezmeyer.com.ar/
More information about the Development
mailing list