[LLVMbugs] [Bug 8450] New: Unexpected error "explicit specialization of 'XXX' after instantiation
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Oct 24 05:26:50 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=8450
Summary: Unexpected error "explicit specialization of 'XXX'
after instantiation
Product: clang
Version: trunk
Platform: Other
OS/Version: FreeBSD
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: kiyolee at hotmail.com
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
Consider the following 2 source files:
// llvm-bug.h
#include <cstdlib>
template<class _Elem>
class MyClass {
public:
static const signed char tbl[256];
static int lookup(const _Elem& c) {
return (c >= 0 && (size_t)c < sizeof(tbl)/sizeof(tbl[0]))
? tbl[(size_t)c] : -1;
}
};
#ifdef WORKAROUND
template<>
const signed char MyClass<char>::tbl[256];
#endif
template<>
int MyClass<char>::lookup(const char& c)
{
return MyClass<char>::tbl[(unsigned char)c];
}
// eof
// llvm-bug.cpp
#include "llvm-bug.h"
template<>
const signed char MyClass<char>::tbl[256] = { 0 };
// eof
Compiling llvm-bug.cpp without the WORKAROUND block would report the following
error:
llvm-bug.cpp:4:34: error: explicit specialization of 'tbl' after instantiation
const signed char MyClass<char>::tbl[256] = { 0 };
^
In file included from llvm-bug.cpp:3:
./llvm-bug.h:19:26: note: implicit instantiation first required here
return MyClass<char>::tbl[(unsigned char)c];
^
1 error generated.
The file would be compiled alright if WORKAROUND block is included and that
does not seem actually correct.
For comparison, g++ accept both with and without the WORKAROUND block.
VC 2008 would report error for the WORKAROUND block instead about member
variable without initializer but initializer in header is wrong either:
duplicate copies of the same static member variable upon linking if the header
is used by multiple .cpp files.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list