Bug 102969 - [12 regression] g++.dg/warn/Wstringop-overflow-4.C fails after r12-4726
Summary: [12 regression] g++.dg/warn/Wstringop-overflow-4.C fails after r12-4726
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: 12.0
Assignee: Martin Sebor
URL:
Keywords: diagnostic
Depends on:
Blocks: Wstringop-overflow
  Show dependency treegraph
 
Reported: 2021-10-27 18:30 UTC by seurer
Modified: 2021-11-11 23:38 UTC (History)
1 user (show)

See Also:
Host:
Target: powerpc64{,le}-linux-gnu, aarch64-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-10-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description seurer 2021-10-27 18:30:43 UTC
g:9a27acc30a34b7854db32eac562306cebac6fa1e, r12-4726
make  -k check-gcc RUNTESTFLAGS="dg.exp=g++.dg/warn/Wstringop-overflow-4.C"
FAIL: g++.dg/warn/Wstringop-overflow-4.C  -std=gnu++98 (test for excess errors)
# of expected passes		59
# of unexpected failures	1

spawn -ignore SIGHUP /home/seurer/gcc/git/build/gcc-test/gcc/testsuite/g++/../../xg++ -B/home/seurer/gcc/git/build/gcc-test/gcc/testsuite/g++/../../ exceptions_enabled844733.cc -fdiagnostics-plain-output -nostdinc++ -I/home/seurer/gcc/git/build/gcc-test/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/powerpc64le-unknown-linux-gnu -I/home/seurer/gcc/git/build/gcc-test/powerpc64le-unknown-linux-gnu/libstdc++-v3/include -I/home/seurer/gcc/git/gcc-test/libstdc++-v3/libsupc++ -I/home/seurer/gcc/git/gcc-test/libstdc++-v3/include/backward -I/home/seurer/gcc/git/gcc-test/libstdc++-v3/testsuite/util -fmessage-length=0 -S -o exceptions_enabled844733.s
FAIL: g++.dg/warn/Wstringop-overflow-4.C  -std=gnu++98 (test for excess errors)
Excess errors:
/home/seurer/gcc/git/gcc-test/gcc/testsuite/g++.dg/warn/Wstringop-overflow-4.C:164:3: warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' writing 3 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]


commit 9a27acc30a34b7854db32eac562306cebac6fa1e (HEAD, refs/bisect/bad)
Author: Martin Sebor <msebor@redhat.com>
Date:   Tue Oct 26 14:38:11 2021 -0600

    Make full use of context-sensitive ranges in access warnings.
Comment 1 Andrew Pinski 2021-10-27 21:02:16 UTC
Confirmed. I noticed this too.
I debugged it a little bit too. The reason why it shows up in C++98 only is because C++98 does the size check slightly different and does not throw an exception in the case of an overflow.
Also You need all 3 checks in the code to get the warning in the first place, that is:
  ptrdiff_t r_dmin_dmax = SR (DIFF_MIN, DIFF_MAX);
  T (S (1), new int16_t[r_dmin_dmax]);
  T (S (2), new int16_t[r_dmin_dmax + 1]);
  T (S (9), new int16_t[r_dmin_dmax * 2 + 1]);

Have just the one which warns does not cause a warning.  I didn't look further than that.
Comment 2 Martin Sebor 2021-11-11 23:31:35 UTC
Looks like this has resolved itself, most likely by one of the changes to make greater use of ranger.  I can't reproduce it with a cross-compiler and don't see the failures in recent test results.
Comment 3 Andrew Pinski 2021-11-11 23:38:05 UTC
(In reply to Martin Sebor from comment #2)
> Looks like this has resolved itself, most likely by one of the changes to
> make greater use of ranger.  I can't reproduce it with a cross-compiler and
> don't see the failures in recent test results.

It was fixed sometime before r12-4939.