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/102690] [12 regression] g++.dg/warn/Warray-bounds-16.C fails
Date: Tue, 12 Oct 2021 06:22:56 +0000	[thread overview]
Message-ID: <bug-102690-4-TlPMmYa3BM@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102690-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102690

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-10-12
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Oh, I can probably fix the

FAIL: g++.dg/warn/Warray-bounds-16.C  -std=gnu++17  scan-tree-dump-not
optimized "goto"

since the expected optimization is not valid.  But the IMHO bogus excess error
remains, see PR101480 for an analysis.  Quote:

--
What we see is the global variable construction function which accesses
just 'a', and yes, the call to 'new' is considered clobbering global
variables (including 'a'):

  <bb 2> [local count: 1073741824]:
  MEM[(struct __as_base  &)&a] ={v} {CLOBBER};
  a.m = 0;
  _5 = operator new [] (0);
  a.p = _5;
  goto <bb 4>; [100.00%]

  <bb 3> [local count: 8687547547]:
  _7 = (long unsigned int) i_6;
  _8 = _7 * 4;
  _9 = _5 + _8;
  MEM[(int *)_9] = 0;
  i_10 = i_6 + 1;

  <bb 4> [local count: 9761289362]:
  # i_6 = PHI <0(2), i_10(3)>
  _11 = a.m;
  if (i_6 < _11)
    goto <bb 3>; [89.00%]
  else
    goto <bb 5>; [11.00%]

  <bb 5> [local count: 1073741824]:
  return;

I suppose implementing the global operator new as accessing a.m would
be valid as IIRC lifetime of a starts when the CTOR is invoked, not
when it finished (otherwise the CTOR could not access the variable itself).

We somehow conclude that

_9: void * [1B, +INF]  EQUIVALENCES: { } (0 elements)

possibly because it cannot be NULL (?):

extract_range_from_stmt visiting:
_5 = operator new [] (0);
Found new range for _5: void * [1B, +INF]
marking stmt to be not simulated again

(huh?)

and then the -Warray-bounds warning concludes the access is always outside
of the allocated area.

I suspect when we'd arrive at VARYING we'd not issue the warning even
when the access would always extend beyond a zero-sized allocation.
--

  parent reply	other threads:[~2021-10-12  6:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-11 20:44 [Bug testsuite/102690] New: " seurer at gcc dot gnu.org
2021-10-11 21:02 ` [Bug tree-optimization/102690] " pinskia at gcc dot gnu.org
2021-10-12  6:21 ` rguenth at gcc dot gnu.org
2021-10-12  6:22 ` rguenth at gcc dot gnu.org [this message]
2021-11-09  0:56 ` seurer at gcc dot gnu.org
2021-11-09  2:30 ` msebor at gcc dot gnu.org
2021-11-09  8:25 ` [Bug testsuite/102690] [11/12 " rguenth at gcc dot gnu.org
2021-11-10  8:55 ` ebotcazou at gcc dot gnu.org
2021-11-10  9:15 ` rguenth at gcc dot gnu.org
2021-11-10 10:10 ` cvs-commit at gcc dot gnu.org
2021-11-10 10:10 ` cvs-commit at gcc dot gnu.org
2021-11-10 10:11 ` rguenth at gcc dot gnu.org
2021-11-10 11:49 ` ebotcazou at gcc dot gnu.org
2022-04-21  7:50 ` rguenth at gcc dot gnu.org
2022-06-30  2:15 ` [Bug testsuite/102690] [11/12/13 " cvs-commit at gcc dot gnu.org
2023-05-29 10:05 ` [Bug testsuite/102690] [11/12/13/14 " jakub at gcc dot gnu.org

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-102690-4-TlPMmYa3BM@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: link
Be 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).