public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/7094: initialized static const value in class disappears sometimes
@ 2002-06-22  4:56 pme
  0 siblings, 0 replies; 2+ messages in thread
From: pme @ 2002-06-22  4:56 UTC (permalink / raw)
  To: dmonksfd, gcc-bugs, gcc-prs, nobody

Synopsis: initialized static const value in class disappears sometimes

State-Changed-From-To: open->closed
State-Changed-By: pme
State-Changed-When: Fri Jun 21 17:53:08 2002
State-Changed-Why:
    Thank you for your bug report.
    
    This is not a bug in GCC; your code is illegal.  You have
    only provided a declaration of a static member, you must
    still provide a definition.  (That's why the linker says
    the variable is undefined -- you haven't defined it.)
    
    You need to add
    
        int C::VALUE;
    
    somewhere.

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


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

* c++/7094: initialized static const value in class disappears sometimes
@ 2002-06-21  4:47 dmonksfd
  0 siblings, 0 replies; 2+ messages in thread
From: dmonksfd @ 2002-06-21  4:47 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7094
>Category:       c++
>Synopsis:       initialized static const value in class disappears sometimes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 21 04:46:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     David Monksfield
>Release:        3.1
>Organization:
>Environment:
Reading specs from /tools/gcc/3.1/i686-2.4.7-10/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc-3.1/configure --prefix=/tools/gcc/3.1 --exec-prefix=/tools/gcc/3.1/i686-2.4.7-10 --disable-nls --enable-shared
>Description:
The attached code (gcc31bug2.cc) refers to an
initialized static const value in a class.  The
linker claims that this value is undefined.
This compiles fine under gcc-2.95.3.

Command:
    g++ gcc31bug2.cc

Output:

/tmp/cc2E65Pk.o: In function `main':
/tmp/cc2E65Pk.o(.text+0x13): undefined reference to `C::VALUE'
collect2: ld returned 1 exit status
>How-To-Repeat:
Compile the following:

struct C
{
    static const int VALUE = 1;
};

template<class T>
void func(const T &val)
{
}

main()
{
    func(C::VALUE);
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2002-06-22  0:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-22  4:56 c++/7094: initialized static const value in class disappears sometimes pme
  -- strict thread matches above, loose matches on Subject: below --
2002-06-21  4:47 dmonksfd

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