public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115435] New: Issue warning for indirect call to pure virtual function in ctor or dtor
@ 2024-06-11 14:24 redi at gcc dot gnu.org
  2024-06-11 14:27 ` [Bug ipa/115435] " pinskia at gcc dot gnu.org
  2024-06-11 14:31 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2024-06-11 14:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115435
           Summary: Issue warning for indirect call to pure virtual
                    function in ctor or dtor
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
            Blocks: 87403
  Target Milestone: ---

We warn about undefined calls to pure virtual functions from constructors and
destructors:

struct Base {
    virtual void f() = 0;
    Base() { f(); }
};

<source>: In constructor 'Base::Base()':
<source>:3:15: warning: pure virtual 'virtual void Base::f()' called from
constructor
    3 |     Base() { f(); }
      |              ~^~


But for indirect calls we don't warn:

struct Base {
    virtual void f() = 0;
    Base() { g(); }
    void g() { f(); }
};

It would be good if IPA could warn for this case too. After g() is inlined into
the constructor we know that the call to f() is undefined.

I assume this would mean moving the warning from the front end to the middle
end.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403
[Bug 87403] [Meta-bug] Issues that suggest a new warning

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

* [Bug ipa/115435] Issue warning for indirect call to pure virtual function in ctor or dtor
  2024-06-11 14:24 [Bug c++/115435] New: Issue warning for indirect call to pure virtual function in ctor or dtor redi at gcc dot gnu.org
@ 2024-06-11 14:27 ` pinskia at gcc dot gnu.org
  2024-06-11 14:31 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-11 14:27 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-06-11
          Component|c++                         |ipa
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
.

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

* [Bug ipa/115435] Issue warning for indirect call to pure virtual function in ctor or dtor
  2024-06-11 14:24 [Bug c++/115435] New: Issue warning for indirect call to pure virtual function in ctor or dtor redi at gcc dot gnu.org
  2024-06-11 14:27 ` [Bug ipa/115435] " pinskia at gcc dot gnu.org
@ 2024-06-11 14:31 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-11 14:31 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=6006

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup. will update that bug.

*** This bug has been marked as a duplicate of bug 47940 ***

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

end of thread, other threads:[~2024-06-11 14:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-11 14:24 [Bug c++/115435] New: Issue warning for indirect call to pure virtual function in ctor or dtor redi at gcc dot gnu.org
2024-06-11 14:27 ` [Bug ipa/115435] " pinskia at gcc dot gnu.org
2024-06-11 14:31 ` pinskia 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).