This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/7094: initialized static const value in class disappears sometimes


>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]