public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "aldyh at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/107561] [13 Regression] g++.dg/pr17488.C and [g++.dg/warn/Warray-bounds-16.C -m32] regression due to -Wstringop-overflow problem
Date: Tue, 08 Nov 2022 08:48:51 +0000	[thread overview]
Message-ID: <bug-107561-4-s05n0l54SX@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107561-4@http.gcc.gnu.org/bugzilla/>

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

Aldy Hernandez <aldyh at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[13 Regression]             |[13 Regression]
                   |g++.dg/pr17488.C regression |g++.dg/pr17488.C and
                   |due to -Wstringop-overflow  |[g++.dg/warn/Warray-bounds-
                   |problem                     |16.C -m32] regression due
                   |                            |to -Wstringop-overflow
                   |                            |problem

--- Comment #2 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
The following test also fails for the same reason:

g++.dg/warn/Warray-bounds-16.C -m32 -O2

It is perhaps a better reduced test for the issue:

inline void* operator new (__SIZE_TYPE__, void * v)
{
  return v;
}

struct S
{
  int* p;
  int m;

  S (int i)
  {
    m = i;
    p = (int*) new unsigned char [sizeof (int) * m];

    for (int i = 0; i < m; i++)
      new (p + i) int (); /* { dg-bogus "bounds" "pr102690" { xfail *-*-* } }
*/
  }
};

S a (0);

$ ./cc1plus a.c -fdump-tree-all-details -quiet -I/tmp -O2 -std=gnu++98 -m32
In constructor ‘S::S(int)’,
    inlined from ‘void __static_initialization_and_destruction_0()’ at
a.c:26:7,
    inlined from ‘(static initializers for a.c)’ at a.c:26:8:
a.c:22:24: warning: ‘void* __builtin_memset(void*, int, unsigned int)’ writing
4 or more bytes into a region of size 0 overflows the destination
[-Wstringop-overflow=]
   22 |       new (p + i) int (); /* { dg-bogus "bounds" "pr102690" { xfail
*-*-* } } */
      |                        ^
a.c:19:51: note: destination object of size 0 allocated by ‘operator new []’
   19 |     p = (int*) new unsigned char [sizeof (int) * m];
      |                                                   ^
+ set +x

The ranges for some pointers are now different as early as .waccess1, even
though the IL is the same:

--- /tmp/a.c.025t.waccess1.orig.805839  2022-11-08 09:46:00.513031310 +0100
+++ /tmp/a.c.025t.waccess1.new.805839   2022-11-08 09:46:00.515031315 +0100
@@ -41,9 +41,9 @@
   max_depth:          2

 pointer_query cache contents:
-  3.0[5]: _3 = _17 (base0); size: unknown
+  3.0[5]: _3 = _17 (base0); size: [4, 2147483647]
   11.0[1]: this_11(D) = this_11(D); size: unknown
-  17.0[3]: _17 = _17 (base0); size: unknown
+  17.0[3]: _17 = _17 (base0); size: [4, 2147483647]

Similarly by evrp time:

-Global Exported: _15 = [irange] unsigned int [0, +INF] NONZERO 0xfffffffc
+Global Exported: _15 = [irange] unsigned int [0, 0][4, +INF] NONZERO
0xfffffffc

etc etc.

The range is correct, as it is the result of a multiplication by a power of 2:

    _15 = _2 * 4;

_15 can never be [1,3].

  parent reply	other threads:[~2022-11-08  8:49 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07 20:06 [Bug tree-optimization/107561] New: g++.dg/pr17488.C " aldyh at gcc dot gnu.org
2022-11-07 20:10 ` [Bug tree-optimization/107561] [13 Regression] " pinskia at gcc dot gnu.org
2022-11-08  8:31 ` aldyh at gcc dot gnu.org
2022-11-08  8:48 ` aldyh at gcc dot gnu.org [this message]
2022-11-08  9:34 ` [Bug tree-optimization/107561] [13 Regression] g++.dg/pr17488.C and [g++.dg/warn/Warray-bounds-16.C -m32] " rguenth at gcc dot gnu.org
2022-11-08 13:43 ` aldyh at gcc dot gnu.org
2022-11-08 18:27 ` pinskia at gcc dot gnu.org
2022-12-14 15:43 ` [Bug tree-optimization/107561] [13 Regression] g++.dg/pr71488.C " danglin at gcc dot gnu.org
2023-01-13 12:42 ` rguenth at gcc dot gnu.org
2023-02-02 18:53 ` hp at gcc dot gnu.org
2023-02-02 21:03 ` hp at gcc dot gnu.org
2023-02-10  0:42 ` cvs-commit at gcc dot gnu.org
2023-02-27  9:56 ` rguenth at gcc dot gnu.org
2023-02-27 11:18 ` rguenth at gcc dot gnu.org
2023-02-27 12:49 ` rguenth at gcc dot gnu.org
2023-02-27 13:45 ` aldyh at gcc dot gnu.org
2023-02-27 14:38 ` redi at gcc dot gnu.org
2023-02-27 16:16 ` aldyh at gcc dot gnu.org
2023-03-01 14:22 ` rguenth at gcc dot gnu.org
2023-03-01 14:34 ` jakub at gcc dot gnu.org
2023-03-01 14:38 ` rguenth at gcc dot gnu.org
2023-03-01 14:55 ` jakub at gcc dot gnu.org
2023-03-01 14:57 ` jakub at gcc dot gnu.org
2023-03-01 15:55 ` redi at gcc dot gnu.org
2023-03-02  7:51 ` rguenth at gcc dot gnu.org
2023-03-02  7:53 ` rguenth at gcc dot gnu.org
2023-03-29 11:38 ` rguenth at gcc dot gnu.org
2023-03-29 11:41 ` rguenth at gcc dot gnu.org
2023-03-30 11:16 ` cvs-commit at gcc dot gnu.org
2023-03-30 11:17 ` rguenth 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-107561-4-s05n0l54SX@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).