public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109350] FAIL: g++.dg/warn/Wstringop-overflow-4.C Date: Fri, 31 Mar 2023 07:17:50 +0000 [thread overview] Message-ID: <bug-109350-4-PLTvMIHDpV@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-109350-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109350 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amacleod at redhat dot com --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- Hmm, the same reproduces with r_imin_imax as ptrdiff_t but the IL is a bit more obvious: <bb 2> [local count: 1073741824]: _27 ={v} signed_value_source; _4 = (unsigned long) _27; _8 = _4 + 2147483648; if (_8 > 4294967295) goto <bb 8>; [50.00%] else goto <bb 3>; [50.00%] <bb 3> [local count: 536870913]: _30 = _27 + 1; _28 = (sizetype) _30; if (_4 <= 4611686018427387900) goto <bb 4>; [50.00%] else goto <bb 5>; [50.00%] <bb 5> [local count: 268435458]: _12 = operator new [] (18446744073709551615); __builtin_memcpy (_12, &MEM <const char[37]> [(void *)"0123456789abcdefghijklmnopqrstuvwxyz" + 35B], 2); sink (_12); if (_28 <= 4611686018427387900) goto <bb 9>; [100.00%] else goto <bb 7>; [0.00%] <bb 9> [local count: 0]: iftmp.2_37 = _28 * 2; _39 = operator new [] (iftmp.2_37); __builtin_memcpy (_39, &MEM <const char[37]> [(void *)"0123456789abcdefghijklmnopqrstuvwxyz" + 34B], 3); so we have (unsigned long)[int_min, int_max] > 4611686018427387900 && (unsigned long)[int_min+1, int_max+1] <= 4611686018427387900 to constrain _4. I don't see how we can arrive at [0,0] for iftmp.2_37. In fact if I put this into a separate testcase like void __attribute__((noipa)) foo (long signed_value_source) { unsigned long temu = signed_value_source; if (temu + 2147483648 > 4294967295) ; else { long tems = signed_value_source + 1; unsigned long temu2 = tems; if (temu > 4611686018427387900) if (temu2 <= 4611686018427387900) { unsigned long iftmp = temu2 * 2; if (iftmp == 0) __builtin_abort (); } } } then we optimize this to <bb 2> [local count: 1073741824]: temu_3 = (long unsigned int) signed_value_source_2(D); _1 = temu_3 + 2147483648; if (_1 > 4294967295) goto <bb 5>; [50.00%] else goto <bb 3>; [50.00%] <bb 3> [local count: 536870913]: if (signed_value_source_2(D) == -1) goto <bb 4>; [0.00%] else goto <bb 5>; [100.00%] <bb 4> [count: 0]: __builtin_abort (); and the outer if doesn't change the inner range result.
next prev parent reply other threads:[~2023-03-31 7:17 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-31 6:09 [Bug tree-optimization/109350] New: " rguenth at gcc dot gnu.org 2023-03-31 6:35 ` [Bug tree-optimization/109350] " rguenth at gcc dot gnu.org 2023-03-31 7:17 ` rguenth at gcc dot gnu.org [this message] 2023-03-31 14:30 ` amacleod at redhat dot com 2023-03-31 20:47 ` amacleod at redhat dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-109350-4-PLTvMIHDpV@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).