public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60277] New: Bogus "inline function virtual ..." used but never defined
@ 2014-02-19 19:57 ppluzhnikov at google dot com
  2014-02-19 21:07 ` [Bug c++/60277] " nlewycky at google dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ppluzhnikov at google dot com @ 2014-02-19 19:57 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60277

            Bug ID: 60277
           Summary: Bogus "inline function virtual ..." used but never
                    defined
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppluzhnikov at google dot com

Test case:

struct Foo {
  inline virtual void func() = 0;
};

struct Bar : public Foo {
  void func() { }
};

int main()
{
  Foo *f = new Bar;
  f->func();
}


Using trunk:
g++ (GCC) 4.9.0 20140219 (experimental)

g++ -c -Wall -Wextra t.cc
t.cc:2:23: warning: inline function 'virtual void Foo::func()' used but never
defined
   inline virtual void func() = 0;
                       ^


But Foo::func is never actually used.

Analysis by Nick Lewycky:


The relevant [basic.odr]/2 text is:
  "A virtual member function is odr-used if it is not pure. A non-overloaded
function whose name appears as a potentially-evaluated expression or a member
of a set of candidate functions, if selected by overload resolution when
referred to from a potentially-evaluated expression, is odr-used, unless it is
a pure virtual function and its name is not explicitly qualified."

Since the function isn't ODR-used, there's no need for it to have a definition:
  "An inline function shall be defined in every translation unit in which it is
odr-used." [basic.odr]/3
>From gcc-bugs-return-444258-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Feb 19 19:57:22 2014
Return-Path: <gcc-bugs-return-444258-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 25321 invoked by alias); 19 Feb 2014 19:57:21 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 25286 invoked by uid 48); 19 Feb 2014 19:57:18 -0000
From: "mark at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/56563] no debuginfo for "explicit" operator
Date: Wed, 19 Feb 2014 19:57:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: debug
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mark at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-56563-4-QOkzoh16tg@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-56563-4@http.gcc.gnu.org/bugzilla/>
References: <bug-56563-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-02/txt/msg02015.txt.bz2
Content-length: 986

http://gcc.gnu.org/bugzilla/show_bug.cgi?idV563

Mark Wielaard <mark at gcc dot gnu.org> changed:

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

--- Comment #4 from Mark Wielaard <mark at gcc dot gnu.org> ---
With the patch we get the following for the example in the description:

 [    37]      subprogram
               external             (flag_present) Yes
               name                 (strp) "operator int"
               decl_file            (data1) 1
               decl_line            (data1) 3
               linkage_name         (strp) "_ZN1qcviEv"
               type                 (ref4) [    51]
               declaration          (flag_present) Yes
               explicit             (flag_present) Yes
               object_pointer       (ref4) [    4a]


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

* [Bug c++/60277] Bogus "inline function virtual ..." used but never defined
  2014-02-19 19:57 [Bug c++/60277] New: Bogus "inline function virtual ..." used but never defined ppluzhnikov at google dot com
@ 2014-02-19 21:07 ` nlewycky at google dot com
  2014-02-21 14:57 ` jason at gcc dot gnu.org
  2021-12-03  5:45 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: nlewycky at google dot com @ 2014-02-19 21:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60277

--- Comment #1 from Nick Lewycky <nlewycky at google dot com> ---
Furthermore, if the testcase ended with:

  f->Foo::func();

then the warning should be issued.


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

* [Bug c++/60277] Bogus "inline function virtual ..." used but never defined
  2014-02-19 19:57 [Bug c++/60277] New: Bogus "inline function virtual ..." used but never defined ppluzhnikov at google dot com
  2014-02-19 21:07 ` [Bug c++/60277] " nlewycky at google dot com
@ 2014-02-21 14:57 ` jason at gcc dot gnu.org
  2021-12-03  5:45 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2014-02-21 14:57 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60277

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Fri Feb 21 14:56:46 2014
New Revision: 208001

URL: http://gcc.gnu.org/viewcvs?rev=208001&root=gcc&view=rev
Log:
    PR c++/60277
    * call.c (build_array_conv): Don't crash on VLA.

Added:
    trunk/gcc/testsuite/g++.dg/cpp1y/vla13.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c


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

* [Bug c++/60277] Bogus "inline function virtual ..." used but never defined
  2014-02-19 19:57 [Bug c++/60277] New: Bogus "inline function virtual ..." used but never defined ppluzhnikov at google dot com
  2014-02-19 21:07 ` [Bug c++/60277] " nlewycky at google dot com
  2014-02-21 14:57 ` jason at gcc dot gnu.org
@ 2021-12-03  5:45 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-03  5:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.3
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=92695

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 9.3.0+ and in GCC 10 by r10-5027-g99150b053e1 and
r9-8069-ge3edafbca9f3553 (PR 92695). The patch includes exactly a testcase
which is similar enough to this one.

So closing as fixed.

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

end of thread, other threads:[~2021-12-03  5:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-19 19:57 [Bug c++/60277] New: Bogus "inline function virtual ..." used but never defined ppluzhnikov at google dot com
2014-02-19 21:07 ` [Bug c++/60277] " nlewycky at google dot com
2014-02-21 14:57 ` jason at gcc dot gnu.org
2021-12-03  5:45 ` 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).