[LLVMbugs] [Bug 1494] NEW: Linking fails when using "static const double" field
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sun Jun 3 13:50:03 PDT 2007
http://llvm.org/bugs/show_bug.cgi?id=1494
Summary: Linking fails when using "static const double" field
Product: new-bugs
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: maarten at treewalker.org
When compiling the following program:
===
template <unsigned N>
class C {
public:
static const double INVERSE = 1.0 / N;
};
double getInverse()
{
return C<14>::INVERSE;
}
int main(int argc, char** argv) {
return 0;
}
// Without this, linking fails on INVERSE.
//template class C<14>;
===
With the command line:
$ llvm-g++ -o inverse inverse.cc
I get this error message:
/tmp/cc4LClWF.o: In function `getInverse()':
(.text+0xd): undefined reference to `C<14u>::INVERSE'
collect2: ld returned 1 exit status
This error goes away when forcing template instantiation by enabling the
commented out line at the end.
In the non-LLVM GCC this compiles and links just fine. However, when compiling
with "-pedantic" it tells you:
inverse.cc:4: error: ISO C++ forbids initialization of member
constant ‘INVERSE’ of non-integral type ‘const double’
So according to the current spec this entire construct is not allowed. But it
would be practical to be compatible with GCC's behaviour, to make more
existing code compile to LLVM.
I'm using LLVM 2.0 and its g++ front-end, compiled from source with GCC 4.1.3.
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the llvm-bugs
mailing list