public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/8166: A static const int class variable becomes an undefined symbol.
@ 2002-10-08  1:42 nathan
  0 siblings, 0 replies; 2+ messages in thread
From: nathan @ 2002-10-08  1:42 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, mgoodman, nobody

Synopsis: A static const int class variable becomes an undefined symbol.

State-Changed-From-To: open->closed
State-Changed-By: nathan
State-Changed-When: Tue Oct  8 01:42:17 2002
State-Changed-Why:
    not a bug. You have only declared the static const, 
    not defined it -- see [9.4.2]/4

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8166


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

* c++/8166: A static const int class variable becomes an undefined symbol.
@ 2002-10-07 19:26 mgoodman
  0 siblings, 0 replies; 2+ messages in thread
From: mgoodman @ 2002-10-07 19:26 UTC (permalink / raw)
  To: gcc-gnats


>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 "<built-in>"
# 1 "<command line>"
# 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:


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

end of thread, other threads:[~2002-10-08  8:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-08  1:42 c++/8166: A static const int class variable becomes an undefined symbol nathan
  -- strict thread matches above, loose matches on Subject: below --
2002-10-07 19:26 mgoodman

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).