public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/98266] New: bogus array subscript is partly outside array bounds on virtual inheritance
@ 2020-12-13 23:32 msebor at gcc dot gnu.org
  2020-12-13 23:33 ` [Bug middle-end/98266] [11 Regression] " msebor at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-12-13 23:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98266
           Summary: bogus array subscript is partly outside array bounds
                    on virtual inheritance
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

As reported in https://bugzilla.redhat.com/show_bug.cgi?id=1907216, GCC 11
issues a spurious -Warray-bounds on the following code (reduced from the
original test case):

$ cat rhbz1738791.C && g++ -O2 -S -Wall rhbz1738791.C
struct A
{
  virtual ~A() noexcept;
  const char* s;
};

struct B: virtual A { };

struct C: virtual B { };

struct D: virtual A { };

struct E: virtual B, virtual D
{
  E (const char*);
};

void f (E);

void g_function ()
{
  f (E (""));
}
rhbz1738791.C: In function ‘void g_function()’:
rhbz1738791.C:11:8: warning: array subscript ‘D[1]’ is partly outside array
bounds of ‘E [1]’ [-Warray-bounds]
   11 | struct D: virtual A { };
      |        ^
rhbz1738791.C:22:11: note: while referencing ‘<anonymous>’
   22 |   f (E (""));
      |           ^
rhbz1738791.C:11:8: warning: array subscript ‘D[1]’ is partly outside array
bounds of ‘E [1]’ [-Warray-bounds]
   11 | struct D: virtual A { };
      |        ^
rhbz1738791.C:22:11: note: while referencing ‘<anonymous>’
   22 |   f (E (""));
      |           ^

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/98266] [11 Regression] bogus array subscript is partly outside array bounds on virtual inheritance
  2020-12-13 23:32 [Bug middle-end/98266] New: bogus array subscript is partly outside array bounds on virtual inheritance msebor at gcc dot gnu.org
@ 2020-12-13 23:33 ` msebor at gcc dot gnu.org
  2020-12-13 23:33 ` msebor at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-12-13 23:33 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-12-13
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=97595
            Summary|bogus array subscript is    |[11 Regression] bogus array
                   |partly outside array bounds |subscript is partly outside
                   |on virtual inheritance      |array bounds on virtual
                   |                            |inheritance
             Status|UNCONFIRMED                 |NEW
             Blocks|                            |56456
     Ever confirmed|0                           |1
   Target Milestone|---                         |11.0
           Keywords|                            |diagnostic

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The problem is most likely the same as in pr97595 (except in
gimple-array-bounds.cc).


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456
[Bug 56456] [meta-bug] bogus/missing -Warray-bounds

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/98266] [11 Regression] bogus array subscript is partly outside array bounds on virtual inheritance
  2020-12-13 23:32 [Bug middle-end/98266] New: bogus array subscript is partly outside array bounds on virtual inheritance msebor at gcc dot gnu.org
  2020-12-13 23:33 ` [Bug middle-end/98266] [11 Regression] " msebor at gcc dot gnu.org
@ 2020-12-13 23:33 ` msebor at gcc dot gnu.org
  2021-01-14 11:07 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-12-13 23:33 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/98266] [11 Regression] bogus array subscript is partly outside array bounds on virtual inheritance
  2020-12-13 23:32 [Bug middle-end/98266] New: bogus array subscript is partly outside array bounds on virtual inheritance msebor at gcc dot gnu.org
  2020-12-13 23:33 ` [Bug middle-end/98266] [11 Regression] " msebor at gcc dot gnu.org
  2020-12-13 23:33 ` msebor at gcc dot gnu.org
@ 2021-01-14 11:07 ` rguenth at gcc dot gnu.org
  2021-01-20  1:31 ` msebor at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-14 11:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/98266] [11 Regression] bogus array subscript is partly outside array bounds on virtual inheritance
  2020-12-13 23:32 [Bug middle-end/98266] New: bogus array subscript is partly outside array bounds on virtual inheritance msebor at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-01-14 11:07 ` rguenth at gcc dot gnu.org
@ 2021-01-20  1:31 ` msebor at gcc dot gnu.org
  2021-02-23 23:12 ` msebor at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-01-20  1:31 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2021-January/563894.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/98266] [11 Regression] bogus array subscript is partly outside array bounds on virtual inheritance
  2020-12-13 23:32 [Bug middle-end/98266] New: bogus array subscript is partly outside array bounds on virtual inheritance msebor at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-01-20  1:31 ` msebor at gcc dot gnu.org
@ 2021-02-23 23:12 ` msebor at gcc dot gnu.org
  2021-03-08 20:39 ` cvs-commit at gcc dot gnu.org
  2021-03-08 20:39 ` msebor at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-02-23 23:12 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=22488

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
See pr22488 for the underlying problem with the difference between DECL_SIZE
and TYPE_SIZE of classes with virtual bases.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/98266] [11 Regression] bogus array subscript is partly outside array bounds on virtual inheritance
  2020-12-13 23:32 [Bug middle-end/98266] New: bogus array subscript is partly outside array bounds on virtual inheritance msebor at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-02-23 23:12 ` msebor at gcc dot gnu.org
@ 2021-03-08 20:39 ` cvs-commit at gcc dot gnu.org
  2021-03-08 20:39 ` msebor at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-08 20:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:f3daa6c0fd8d79ae45eac2dd0f274da1aa71c958

commit r11-7563-gf3daa6c0fd8d79ae45eac2dd0f274da1aa71c958
Author: Martin Sebor <msebor@redhat.com>
Date:   Mon Mar 8 13:37:21 2021 -0700

    PR middle-end/98266 - bogus array subscript is partly outside array bounds
on virtual inheritance

    gcc/ChangeLog:

            PR middle-end/98266
            * gimple-array-bounds.cc (inbounds_vbase_memaccess_p): New
function.
            (array_bounds_checker::check_array_bounds): Call it.

    gcc/testsuite/ChangeLog:

            PR middle-end/98266
            * g++.dg/warn/Warray-bounds-15.C: New test.
            * g++.dg/warn/Warray-bounds-18.C: New test.
            * g++.dg/warn/Warray-bounds-19.C: New test.
            * g++.dg/warn/Warray-bounds-20.C: New test.
            * g++.dg/warn/Warray-bounds-21.C: New test.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/98266] [11 Regression] bogus array subscript is partly outside array bounds on virtual inheritance
  2020-12-13 23:32 [Bug middle-end/98266] New: bogus array subscript is partly outside array bounds on virtual inheritance msebor at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-03-08 20:39 ` cvs-commit at gcc dot gnu.org
@ 2021-03-08 20:39 ` msebor at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-08 20:39 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
Fixed in r11-7563.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-08 20:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-13 23:32 [Bug middle-end/98266] New: bogus array subscript is partly outside array bounds on virtual inheritance msebor at gcc dot gnu.org
2020-12-13 23:33 ` [Bug middle-end/98266] [11 Regression] " msebor at gcc dot gnu.org
2020-12-13 23:33 ` msebor at gcc dot gnu.org
2021-01-14 11:07 ` rguenth at gcc dot gnu.org
2021-01-20  1:31 ` msebor at gcc dot gnu.org
2021-02-23 23:12 ` msebor at gcc dot gnu.org
2021-03-08 20:39 ` cvs-commit at gcc dot gnu.org
2021-03-08 20:39 ` msebor at gcc dot gnu.org

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).