From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29662 invoked by alias); 8 Oct 2002 02:26:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 29639 invoked by uid 71); 8 Oct 2002 02:26:02 -0000 Resent-Date: 8 Oct 2002 02:26:02 -0000 Resent-Message-ID: <20021008022602.29638.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, mgoodman@csua.berkeley.edu Received: (qmail 29467 invoked from network); 8 Oct 2002 02:23:38 -0000 Received: from unknown (HELO vodka.corp.google.com) (216.239.45.4) by sources.redhat.com with SMTP; 8 Oct 2002 02:23:38 -0000 Received: from vodka.corp.google.com (localhost.localdomain [127.0.0.1]) by vodka.corp.google.com (8.12.5/8.12.5) with ESMTP id g982NQXd020539 for ; Mon, 7 Oct 2002 19:23:26 -0700 Received: (from markg@localhost) by vodka.corp.google.com (8.12.5/8.12.5/Submit) id g982NQOS020537; Mon, 7 Oct 2002 19:23:26 -0700 Message-Id: <200210080223.g982NQOS020537@vodka.corp.google.com> Date: Mon, 07 Oct 2002 19:26:00 -0000 From: mgoodman@csua.berkeley.edu To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: 3.113 Subject: c++/8166: A static const int class variable becomes an undefined symbol. X-SW-Source: 2002-10/txt/msg00275.txt.bz2 List-Id: >Number: 8166 >Category: c++ >Synopsis: A static const int class variable becomes an undefined symbol. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Mon Oct 07 19:26:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: mgoodman@csua.berkeley.edu >Release: 3.3 20021007 (experimental) >Organization: >Environment: System: Linux vodka 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386 GNU/Linux Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ../gcc/configure --prefix=/home2/markg/local --enable-languages=c,c++ >Description: A static const int class variable becomes an undefined symbol in the object file. Since the constructor refers to it, the object file does not link. The bug is also filed at https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=75308. In that bug, I found the behavior in Red Hat 8's gcc 3.2. This bug is filed against CVS. [markg@vodka markg]$ g++ testclass.cc -o testclass /tmp/ccaUlTGx.o: In function `TestClass::TestClass[in-charge](TestClass const*)': /tmp/ccaUlTGx.o(.gnu.linkonce.t._ZN9TestClassC1EPKS_+0x1e): undefined reference to `TestClass::notDefined' collect2: ld returned 1 exit status >How-To-Repeat: g++ testclass.cc -o testclass The preprocessed source is below. # 1 "testclass.cc" # 1 "" # 1 "" # 1 "testclass.cc" # 1 "/home2/markg/local/include/c++/3.3/cstddef" 1 3 # 47 "/home2/markg/local/include/c++/3.3/cstddef" 3 # 1 "/home2/markg/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/include/stddef.h" 1 3 4 # 151 "/home2/markg/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/include/stddef.h" 3 4 typedef int ptrdiff_t; # 213 "/home2/markg/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/include/stddef.h" 3 4 typedef unsigned int size_t; # 49 "/home2/markg/local/include/c++/3.3/cstddef" 2 3 namespace std { using ::ptrdiff_t; using ::size_t; } # 2 "testclass.cc" 2 class TestClass { public: static const int notDefined = -1; TestClass(const TestClass *parent) { i = parent ? parent->i : notDefined; } private: int i; }; TestClass test(__null); int main(void) { return 0; } >Fix: >Release-Note: >Audit-Trail: >Unformatted: