On 12/2/20 1:31 PM, Jeff Law wrote:
On 12/2/20 11:43 AM, Martin Sebor wrote:
The r11-5622 change to -Wformat-overflow switched the warning
to using the maximm object size limit used by the other overflow
and out of bounds access warnings like -Wstringop-overflow.
That in turn exposed a subtle off-by-one mistake in the former
that was also reflected in a few tests, seen in ILP32 but not
in LP64. I just committed the attached patch adjusts the tests
to correctly reflect the limit. These mistakes would be easier
to avoid if if were possible to lower the max object size limit
from PTRDIFF_MAX - 1 to a value that's independent of the target
as in the following patch:
https://gcc.gnu.org/pipermail/gcc-patches/2020-November/559450.html
Martin
gcc-sprintf-max-objsize.diff
commit 0a7dc4b6440faa8cd57c630f1e394a719469c399
Author: Martin Sebor <mse...@redhat.com>
Date: Wed Dec 2 11:29:11 2020 -0700
Adjust test to avoid ILP32 failures after r11-5622 (PR middle-end/97373)
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Adjust expected
warnings
to correctly reflect the maximum object size.
* gcc.dg/tree-ssa/builtin-sprintf-warn-11.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf-warn-18.c: Same.
Still seeing regressions. mcore-elf for example:
I didn't fully revert the max-object-size patch from my tree when
I tested the changes so the fixes I made to the tests were based
on the fixes for the one-off bugs the parameter exposed in
the warning code. I've tweaked the tests to undo the changes with
the dependencies on the fixes. I tested them on x86_64 with both
-m32 and -m64, as well as with mcore-elf and or1k-elf crosses.
builtin-sprintf-warn-18.c is unsupported because it needs iconv
but the other two pass so hopefully this is the last iteration.
Martin
Tests that now fail, but worked before (4 tests):
moxie-sim: gcc.dg/tree-ssa/builtin-sprintf-warn-1.c (test for excess errors)
moxie-sim: gcc.dg/tree-ssa/builtin-sprintf-warn-11.c (test for excess
errors)
And in the log file:
FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-1.c (test for excess errors)
Excess errors:
/home/jenkins/gcc/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c:119:3:
warning: '__builtin_sprintf' writing a terminating nul past the end of
the destination [-Wformat-overflow=]
/home/jenkins/gcc/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c:121:3:
warning: '__builtin_sprintf' writing a terminating nul past the end of
the destination [-Wformat-overflow=]
/home/jenkins/gcc/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c:122:3:
warning: '%*c' directive writing 2147483647 bytes into a region of size
2147483646 [-Wformat-overflow=]
/home/jenkins/gcc/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c:125:3:
warning: '%*c' directive writing 2147483646 bytes into a region of size
1 [-Wformat-overflow=]
/home/jenkins/gcc/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c:130:3:
warning: '__builtin_sprintf' writing a terminating nul past the end of
the destination [-Wformat-overflow=]
/home/jenkins/gcc/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c:131:3:
warning: 'X' directive writing 1 byte into a region of size 0
[-Wformat-overflow=]
/home/jenkins/gcc/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c:299:3:
warning: '__builtin_sprintf' writing a terminating nul past the end of
the destination [-Wformat-overflow=]
/home/jenkins/gcc/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c:300:3:
warning: '%*s' directive writing 2147483647 bytes into a region of size
2147483646 [-Wformat-overflow=]
And:
FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-11.c (test for excess errors)
Excess errors:
/home/jenkins/gcc/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-11.c:207:3:
warning: '__builtin_sprintf' writing a terminating nul past the end of
the destination [-Wformat-overflow=]
/home/jenkins/gcc/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-11.c:215:3:
warning: '%*.*s' directive writing between 5 and 6 bytes into a region
of size between 2 and 4 [-Wformat-overflow=]
Again, I think you can look at these with a simple cross compiler. I
don't think you need cross-binutils, newlib, etc.
jeff