[LLVMbugs] [Bug 12350] New: problem with explicitely calling class destructor if full qualified class name is used

1 view
Skip to first unread message

bugzill...@llvm.org

unread,
Mar 25, 2012, 11:35:38 AM3/25/12
to llvm...@cs.uiuc.edu
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: unassigne...@nondot.org
ReportedBy: dmar...@mac.com
CC: dgr...@apple.com, llvm...@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.
_______________________________________________
LLVMbugs mailing list
LLVM...@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply all
Reply to author
Forward
0 new messages