public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer
@ 2021-05-27 10:37 sbergman at redhat dot com
  2021-05-27 16:23 ` [Bug c++/100797] [9/10/11/12 Regression] " ppalka at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: sbergman at redhat dot com @ 2021-05-27 10:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100797
           Summary: using declaration causing virtual call with wrongly
                    adjusted this pointer
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sbergman at redhat dot com
  Target Milestone: ---

(I stripped this down from an issue found in LibreOffice,
<https://git.libreoffice.org/core/+/0d3dd9d9f6f0e6236c8db8ebdea44c78854639a8%5E%21>
"tdf#142467 crash on calling 'getInfoHelper' in final class", where the
original code had the most derived class, S4 in the below stripped down
example, marked as final, and where removing the "final" fixed things.  In the
below stripped down example, there is no difference in behavior whether or not
S4 is marked final, but I hope the issue exposed by the stripped down example
is still the same as the one originally experienced in the LibreOffice code.)

At least with gcc-11.1.1-1.fc34.x86_64 and with a recent trunk build towards
GCC 12:

> $ cat test.cc
> #include <iostream>
> struct S1 { virtual ~S1() = default; };
> struct S2 { virtual void f1() = 0; };
> struct S3: S1, S2 {
>     void f1() { f2(); }
>     virtual void f2() = 0;
> };
> struct S4: S3 {
>     void f2() { std::cout << "called\n"; }
>     using S2::f1;
> };
> int main() { S4().f1(); }

> $ g++ test.cc
> $ ./a.out
> Segmentation fault

instead of printing "called".  The issue goes away when removing the

  using S2::f1;

declaration from S4.

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

* [Bug c++/100797] [9/10/11/12 Regression] using declaration causing virtual call with wrongly adjusted this pointer
  2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
@ 2021-05-27 16:23 ` ppalka at gcc dot gnu.org
  2021-05-27 16:25 ` ppalka at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-05-27 16:23 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|using declaration causing   |[9/10/11/12 Regression]
                   |virtual call with wrongly   |using declaration causing
                   |adjusted this pointer       |virtual call with wrongly
                   |                            |adjusted this pointer
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org
     Ever confirmed|0                           |1
           Keywords|                            |wrong-code
      Known to work|                            |10.1.0, 9.3.0
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |9.5
      Known to fail|                            |10.2.0, 10.3.0, 11.1.0
   Last reconfirmed|                            |2021-05-27

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Seems to have started with r11-1637, aka the fix for PR95719, which was also
backported to the 10 and 9 branch.

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

* [Bug c++/100797] [9/10/11/12 Regression] using declaration causing virtual call with wrongly adjusted this pointer
  2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
  2021-05-27 16:23 ` [Bug c++/100797] [9/10/11/12 Regression] " ppalka at gcc dot gnu.org
@ 2021-05-27 16:25 ` ppalka at gcc dot gnu.org
  2021-05-28  3:24 ` jason at gcc dot gnu.org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-05-27 16:25 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |9.4

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

* [Bug c++/100797] [9/10/11/12 Regression] using declaration causing virtual call with wrongly adjusted this pointer
  2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
  2021-05-27 16:23 ` [Bug c++/100797] [9/10/11/12 Regression] " ppalka at gcc dot gnu.org
  2021-05-27 16:25 ` ppalka at gcc dot gnu.org
@ 2021-05-28  3:24 ` jason at gcc dot gnu.org
  2021-05-28  9:23 ` cvs-commit at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2021-05-28  3:24 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

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

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

* [Bug c++/100797] [9/10/11/12 Regression] using declaration causing virtual call with wrongly adjusted this pointer
  2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
                   ` (2 preceding siblings ...)
  2021-05-28  3:24 ` jason at gcc dot gnu.org
@ 2021-05-28  9:23 ` cvs-commit at gcc dot gnu.org
  2021-05-28 10:42 ` [Bug c++/100797] [10/11/12 " rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-28  9:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

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

commit r9-9558-gebfe8b28d40746ff33724bd5b9ade2552e619213
Author: Jason Merrill <jason@redhat.com>
Date:   Thu May 27 23:54:52 2021 -0400

    c++: 'this' adjustment for devirtualized call

    My patch for 95719 made us do a better job of finding the actual virtual
    function we want to call, but didn't update the 'this' pointer adjustment
to
    match.

    This backport also incorporates a bit of the r11-1638 reorganization.

            PR c++/100797
            PR c++/95719

    gcc/cp/ChangeLog:

            * call.c (build_over_call): Adjust base_binfo in
            resolves_to_fixed_type_p case.

    gcc/testsuite/ChangeLog:

            * g++.dg/inherit/virtual15.C: New test.
            * g++.dg/inherit/virtual15a.C: New test.

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

* [Bug c++/100797] [10/11/12 Regression] using declaration causing virtual call with wrongly adjusted this pointer
  2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
                   ` (3 preceding siblings ...)
  2021-05-28  9:23 ` cvs-commit at gcc dot gnu.org
@ 2021-05-28 10:42 ` rguenth at gcc dot gnu.org
  2021-05-28 12:58 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-28 10:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2
            Summary|[9/10/11/12 Regression]     |[10/11/12 Regression] using
                   |using declaration causing   |declaration causing virtual
                   |virtual call with wrongly   |call with wrongly adjusted
                   |adjusted this pointer       |this pointer

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
I've pushed a fix to the GCC 9 branch.

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

* [Bug c++/100797] [10/11/12 Regression] using declaration causing virtual call with wrongly adjusted this pointer
  2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
                   ` (4 preceding siblings ...)
  2021-05-28 10:42 ` [Bug c++/100797] [10/11/12 " rguenth at gcc dot gnu.org
@ 2021-05-28 12:58 ` cvs-commit at gcc dot gnu.org
  2021-05-28 13:04 ` jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-28 12:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r12-1114-gf838e3ccf8d2849980e9d0f70aa60ecd2eb5772c
Author: Jason Merrill <jason@redhat.com>
Date:   Thu May 27 23:54:52 2021 -0400

    c++: 'this' adjustment for devirtualized call

    My patch for 95719 made us do a better job of finding the actual virtual
    function we want to call, but didn't update the 'this' pointer adjustment
to
    match.

            PR c++/100797
            PR c++/95719

    gcc/cp/ChangeLog:

            * call.c (build_over_call): Adjust base_binfo in
            resolves_to_fixed_type_p case.

    gcc/testsuite/ChangeLog:

            * g++.dg/inherit/virtual15.C: New test.

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

* [Bug c++/100797] [10/11/12 Regression] using declaration causing virtual call with wrongly adjusted this pointer
  2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
                   ` (5 preceding siblings ...)
  2021-05-28 12:58 ` cvs-commit at gcc dot gnu.org
@ 2021-05-28 13:04 ` jason at gcc dot gnu.org
  2021-05-31  6:26 ` sbergman at redhat dot com
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2021-05-28 13:04 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

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

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Stephan, can you verify that this fixes the LibreOffice issue?

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

* [Bug c++/100797] [10/11/12 Regression] using declaration causing virtual call with wrongly adjusted this pointer
  2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
                   ` (6 preceding siblings ...)
  2021-05-28 13:04 ` jason at gcc dot gnu.org
@ 2021-05-31  6:26 ` sbergman at redhat dot com
  2021-06-01  8:21 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sbergman at redhat dot com @ 2021-05-31  6:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Stephan Bergmann <sbergman at redhat dot com> ---
(In reply to Jason Merrill from comment #5)
> Stephan, can you verify that this fixes the LibreOffice issue?

Yes, thanks, tested the master branch fix and it fixes the LibreOffice issue
for me.

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

* [Bug c++/100797] [10/11/12 Regression] using declaration causing virtual call with wrongly adjusted this pointer
  2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
                   ` (7 preceding siblings ...)
  2021-05-31  6:26 ` sbergman at redhat dot com
@ 2021-06-01  8:21 ` rguenth at gcc dot gnu.org
  2021-06-01  8:43 ` [Bug c++/100797] [10/11 " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:21 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

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

* [Bug c++/100797] [10/11 Regression] using declaration causing virtual call with wrongly adjusted this pointer
  2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
                   ` (8 preceding siblings ...)
  2021-06-01  8:21 ` rguenth at gcc dot gnu.org
@ 2021-06-01  8:43 ` rguenth at gcc dot gnu.org
  2021-06-01 15:53 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |9.4.0
      Known to fail|                            |9.3.1
            Summary|[10/11/12 Regression] using |[10/11 Regression] using
                   |declaration causing virtual |declaration causing virtual
                   |call with wrongly adjusted  |call with wrongly adjusted
                   |this pointer                |this pointer
   Target Milestone|9.5                         |10.4

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

* [Bug c++/100797] [10/11 Regression] using declaration causing virtual call with wrongly adjusted this pointer
  2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
                   ` (9 preceding siblings ...)
  2021-06-01  8:43 ` [Bug c++/100797] [10/11 " rguenth at gcc dot gnu.org
@ 2021-06-01 15:53 ` cvs-commit at gcc dot gnu.org
  2021-06-01 15:53 ` cvs-commit at gcc dot gnu.org
  2021-06-01 19:16 ` jason at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-01 15:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:7c61ce59421547194647a847263b2b9065a26e03

commit r11-8494-g7c61ce59421547194647a847263b2b9065a26e03
Author: Jason Merrill <jason@redhat.com>
Date:   Thu May 27 23:54:52 2021 -0400

    c++: 'this' adjustment for devirtualized call

    My patch for 95719 made us do a better job of finding the actual virtual
    function we want to call, but didn't update the 'this' pointer adjustment
to
    match.

            PR c++/100797
            PR c++/95719

    gcc/cp/ChangeLog:

            * call.c (build_over_call): Adjust base_binfo in
            resolves_to_fixed_type_p case.

    gcc/testsuite/ChangeLog:

            * g++.dg/inherit/virtual15.C: New test.

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

* [Bug c++/100797] [10/11 Regression] using declaration causing virtual call with wrongly adjusted this pointer
  2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
                   ` (10 preceding siblings ...)
  2021-06-01 15:53 ` cvs-commit at gcc dot gnu.org
@ 2021-06-01 15:53 ` cvs-commit at gcc dot gnu.org
  2021-06-01 19:16 ` jason at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-01 15:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:1027e8c8837d9d4933946f2888d85deef2cf850b

commit r10-9876-g1027e8c8837d9d4933946f2888d85deef2cf850b
Author: Jason Merrill <jason@redhat.com>
Date:   Thu May 27 23:54:52 2021 -0400

    c++: 'this' adjustment for devirtualized call

    My patch for 95719 made us do a better job of finding the actual virtual
    function we want to call, but didn't update the 'this' pointer adjustment
to
    match.

    This backport also incorporates a bit of the r11-1638 reorganization.

            PR c++/100797
            PR c++/95719

    gcc/cp/ChangeLog:

            * call.c (build_over_call): Adjust base_binfo in
            resolves_to_fixed_type_p case.

    gcc/testsuite/ChangeLog:

            * g++.dg/inherit/virtual15.C: New test.
            * g++.dg/inherit/virtual15a.C: New test.

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

* [Bug c++/100797] [10/11 Regression] using declaration causing virtual call with wrongly adjusted this pointer
  2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
                   ` (11 preceding siblings ...)
  2021-06-01 15:53 ` cvs-commit at gcc dot gnu.org
@ 2021-06-01 19:16 ` jason at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2021-06-01 19:16 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|10.4                        |9.4

--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 9.4/10.4/11.2/12.

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

end of thread, other threads:[~2021-06-01 19:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 10:37 [Bug c++/100797] New: using declaration causing virtual call with wrongly adjusted this pointer sbergman at redhat dot com
2021-05-27 16:23 ` [Bug c++/100797] [9/10/11/12 Regression] " ppalka at gcc dot gnu.org
2021-05-27 16:25 ` ppalka at gcc dot gnu.org
2021-05-28  3:24 ` jason at gcc dot gnu.org
2021-05-28  9:23 ` cvs-commit at gcc dot gnu.org
2021-05-28 10:42 ` [Bug c++/100797] [10/11/12 " rguenth at gcc dot gnu.org
2021-05-28 12:58 ` cvs-commit at gcc dot gnu.org
2021-05-28 13:04 ` jason at gcc dot gnu.org
2021-05-31  6:26 ` sbergman at redhat dot com
2021-06-01  8:21 ` rguenth at gcc dot gnu.org
2021-06-01  8:43 ` [Bug c++/100797] [10/11 " rguenth at gcc dot gnu.org
2021-06-01 15:53 ` cvs-commit at gcc dot gnu.org
2021-06-01 15:53 ` cvs-commit at gcc dot gnu.org
2021-06-01 19:16 ` jason 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).