From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway32.websitewelcome.com (gateway32.websitewelcome.com [192.185.145.187]) by sourceware.org (Postfix) with ESMTPS id 69B23384F023 for ; Sun, 6 Jun 2021 21:41:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 69B23384F023 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=mad-scientist.net Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=mad-scientist.net Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway32.websitewelcome.com (Postfix) with ESMTP id C72554427B for ; Sun, 6 Jun 2021 16:41:39 -0500 (CDT) Received: from box5922.bluehost.com ([162.241.30.80]) by cmsmtp with SMTP id q0WZl1rOSx8Dpq0WZlktgR; Sun, 06 Jun 2021 16:41:39 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mad-scientist.us; s=default; h=Content-Transfer-Encoding:MIME-Version: Content-Type:Date:To:Reply-To:From:Subject:Message-ID:Sender:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=3eOlWV2WpB0p/MWZPP7i7tXpXwkSSdtOA39HAOCOXr0=; b=tSD56BD1SHvT4Gin/KCCibRVOG HUOb0bihGo2Turk2xmwEb54a+OcFFaWxfn/yhP6jPuXq8X5qbORFf07woa1oBk46OGJJyf89EgUz0 Hz4R4miwD2e3CqPkiP7BedYpW; Received: from pool-96-233-64-159.bstnma.fios.verizon.net ([96.233.64.159]:48198 helo=pdslaptop.home.arpa) by box5922.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lq0WZ-001OMx-G7 for gcc@gcc.gnu.org; Sun, 06 Jun 2021 15:41:39 -0600 Message-ID: Subject: GCC 10.2: undefined reference to vtable: missing its key function From: Paul Smith Reply-To: paul@mad-scientist.net To: "gcc@gcc.gnu.org" Date: Sun, 06 Jun 2021 17:41:38 -0400 Organization: Please remain calm--I may be mad but I am a professional! Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.4-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5922.bluehost.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mad-scientist.net X-BWhitelist: no X-Source-IP: 96.233.64.159 X-Source-L: No X-Exim-ID: 1lq0WZ-001OMx-G7 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: pool-96-233-64-159.bstnma.fios.verizon.net (pdslaptop.home.arpa) [96.233.64.159]:48198 X-Source-Auth: paul@mad-scientist.us X-Email-Count: 1 X-Source-Cap: bWFkc2NpZTE7bWFkc2NpZTE7Ym94NTkyMi5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jun 2021 21:41:42 -0000 I have a class which is NOT, as far as I can see, polymorphic. It doesn't inherit from any other class and none of its methods are declared virtual. The class implementation and all its callers all compile just fine. Is there some other way that a class can be thought to be virtual, stealthily (say by its usage in some other class or something)? The problem is that when I link this class I get a linker error from gold: MyClass.h:25: error: undefined reference to 'vtable for MyClass' ld: the vtable symbol may be undefined because the class is missing its key function Line 25 is the first method in the class (a constructor). Sure enough if I use nm -C on the other object files I'm linking, I see things like this: foo.o: U vtable for MyClass How can I figure out why the compiler decides, while compiling foo.cxx, that MyClass is virtual and needs a vtable when as far as I can tell it's not (if I use nm on MyClass.o I see no hints of vtable etc.) This is with GCC 10.2 / binutils 2.35.1 (x86_64)