[LLVMbugs] [Bug 12350] New: problem with explicitely calling class destructor if full qualified class name is used
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Mar 25 08:35:38 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=12350
Bug #: 12350
Summary: problem with explicitely calling class destructor if
full qualified class name is used
Product: clang
Version: trunk
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: enhancement
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: dmarkman at mac.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Consider the following code:
#include <iostream>
#include <string>
int main(int argc, const char * argv[])
{
char data[ sizeof(std::string) ];
new (data) std::string("Hello World!");
std::string *str = reinterpret_cast<std::string *>(data);
std::cout << *str << std::endl;
str->std::string::~string();//clang failure
return 0;
}
with Xcode 4.3.2 on Lion 10.7.3
g++ ((GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00))
does compile it, but clang++ (clang version 3.1 (trunk 153412))
from the trunk (just built it today)reports an error
main.cpp:11:24: error: expected the class name after '~' to name a destructor
str->std::string::~string();//clang failure
Note:
workarounds are easy
1. using typedef
typedef std::string my_string;
str->~my_string();
BTW: clang doesn't like
str->my_string::~my_string();
but g++ is OK.
2. using keyword "using"
using std::string;
str->~string();
3. using template function
template<typename T>
inline void destroy(T *t) {
t->T::~T();
}
.....
destroy(str);
bottom line: it looks like if I use namespace in the class name clang isn't
happy
--
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