---------- Forwarded message --------- From: Kalamatee <kalamatee@xxxxxxxxx> Date: Thu, 14 Feb 2019 at 10:35 Subject: Re: format-truncation To: Jonathan Wakely <jwakely.gcc@xxxxxxxxx> On Thu, 14 Feb 2019 at 10:27, Kalamatee <kalamatee@xxxxxxxxx> wrote: > > > On Thu, 14 Feb 2019 at 10:19, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> > wrote: > >> On Thu, 14 Feb 2019 at 10:11, Kalamatee <kalamatee@xxxxxxxxx> wrote: >> > >> > Hello >> > >> > I am having trouble identifying how to fix the following error we >> encounter >> > when compiling AROS using our patched gcc 8.2. >> > >> > Compile failed: ccache >> > >> /home/nick/builds/pc-x86_64-smp-gcc8/bin/linux-x86_64/tools/crosstools/x86_64-aros-gcc >> > -iquote >> > >> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/components/utilities/ >> > -iquote /mnt/c/Users/kalam/AROS/svn-repo/AROS/arch/all-pc/acpica >> -iquote . >> > -mcmodel=large -mno-red-zone -mno-ms-bitfields -O2 >> > -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -Wall -Werror >> > -Wno-pointer-sign -Wno-parentheses -Wno-strict-aliasing >> > >> -I/home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/AROS/Developer/include/acpica >> > -iquote >> > >> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/include >> > -iquote >> > >> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/include/platform >> > -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_PERSONAL >> > >> -I/home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/gen/arch/all-pc/acpica/acpica/include >> > -include >> > >> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/gen/arch/all-pc/acpica/acpica/include/acpica_deflibdefs.h >> > >> -D__SRCFILENAME__="bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/components/utilities/utprint.c" >> > -c >> > >> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/components/utilities/utprint.c >> > -o >> > >> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/gen/arch/all-pc/acpica/acpica/utprint.o >> > >> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/components/utilities/utprint.c: >> > In function 'sprintf': >> > >> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/components/utilities/utprint.c:880:14: >> > error: specified bound 4294967295 exceeds 'INT_MAX' >> > [-Werror=format-truncation=] >> > Length = vsnprintf (String, ACPI_UINT32_MAX, Format, Args); >> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> > cc1: all warnings being treated as errors >> > mmakefile:918: recipe for target >> > >> '/home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/gen/arch/all-pc/acpica/acpica/utprint.o' >> > failed >> > >> > My problem is I cannot see where it is getting "INT_MAX" from as the >> bounds >> > for the 2nd parameter. >> > >> > The documentation for vsnprintf says "If the *maxlen* value is 0, no >> > characters are written, and *vsnprintf* returns 0. If the value is >> greater >> > than *INT_MAX* , then *vsnprintf* behaves identically to *vsprintf* in >> that >> >> Isn't that where it's coming from? >> >> The warning is telling you that the output could be unchecked, e.g. if >> it writes UINT32_MAX+1 then it would overflow your buffer. >> > > That's not what the warning/error is saying? It says ACPI_UNIT32_MAX > exceeds INT_MAX. It seems a bit misleading/confusing when it is valid for > the second parameter to take values over INT_MAX. > > My point is - if it generated a warning/error for "UNIT32_MAX + 1" that _would_ be acceptable - but UNIT32_MAX itself is a constant and it can see at compile time that can not over flow the buffer. > I'm aware I can disable the diagnostic - but I don't like turning them off > for one function (when that may hide other functions with real issues), but > I guess there is no other option to stop this? > >