On Fri, Jan 24, 2020 at 07:12:49AM +0500, ???? ??????? wrote: > ??, 24 ???. 2020 ?. ? 01:04, ???? ??????? <chipits...@gmail.com>: > > > > > > > ??, 24 ???. 2020 ?. ? 00:54, Willy Tarreau <w...@1wt.eu>: > > > >> On Fri, Jan 24, 2020 at 12:46:12AM +0500, ???? ??????? wrote: > >> > > diff --git a/Makefile b/Makefile > >> > > index 8399f6ca35..4757bc77e6 100644 > >> > > --- a/Makefile > >> > > +++ b/Makefile > >> > > @@ -199,6 +199,7 @@ SPEC_CFLAGS += $(call > >> cc-opt,-Wshift-negative-value) > >> > > SPEC_CFLAGS += $(call cc-opt,-Wshift-overflow=2) > >> > > SPEC_CFLAGS += $(call cc-opt,-Wduplicated-cond) > >> > > SPEC_CFLAGS += $(call cc-opt,-Wnull-dereference) > >> > > +SPEC_CFLAGS += $(call cc-opt,-Walloc-size-larger-than=-1) > >> > > > >> > > >> > > >> > CC src/cfgparse.o > >> > src/cfgparse.c: In function 'check_config_validity': > >> > src/cfgparse.c:3642:33: warning: product '2147483648 * 8' of arguments 1 > >> > and 2 exceeds 'SIZE_MAX' [-Walloc-size-larger-than=] > >> > >> Pfff.... The only good news is that it takes -1 as SIZE_MAX. > >> > >> > newsrv->idle_orphan_conns = calloc((unsigned int)global.nbthread, > >> > sizeof(*newsrv->idle_orphan_conns)); > >> > > >> > > >> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > >> > src/cfgparse.c:3642:33: note: argument 1 in the range [2147483648, > >> > 4294967295] > >> (...) > >> > why is it complaining about "product '2147483648 * 8" ? > >> > >> because calloc multiplies the two fields and gcc decided that the largest > >> value we could possibly pass to the first one if we were as stupid as it > >> is is 2147483648. Interestingly it took the largest negative value turned > >> to positive and ignored the positive ones that can be turned to the second > >> half that are negative if nbthread was negative. > >> > >> I really think this test is totally bogus and that there is no way to > >> express it correctly. I mean, gcc only lets us use 8, 16, 32 or 64 bits. > >> If you need to calloc a few megabytes, you'll be forced to apply a mask > >> to the value just to shut it up, and *create* the overflow problem > >> yourself > >> when it didn't exist. > >> > >> Let's give up on this one if it doesn't cause too much trouble to you. > >> Otherwise we might cheat doing this : > >> > >> calloc((unsigned short)global.nbthread, ...) > >> > >> But I really despise this given that we have to make the code wrong just > >> to please this shitty compiler. > >> > > > > > > it was ubuntu 18.04 + gcc8, I'll try 19.10 + gcc9 > > > > gcc9 produces the same warning
OK thanks. Willy