This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/32241] Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template
- From: "fang at csl dot cornell dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jun 2007 00:03:18 -0000
- Subject: [Bug c++/32241] Compiler segmentation fault when trying to call x.~X(); (X &x = f();) in a template
- References: <bug-32241-14668@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from fang at csl dot cornell dot edu 2007-06-08 00:03 -------
reduced test case:
==============================
template <typename T>
class SimpleStack {
public:
T& top() { return *ptr; }
void pop() { top.~T(); }
T *ptr;
};
int main(int, char*[]) {
SimpleStack<int> stack;
stack.pop();
return 0;
}
==============================
also ICEs 4.0.1 (apple) and 4.2.0.
keyword: ice-on-invalid
known to fail: 4.0.1, 4.2.0
3.3 (apple) gives:
error: destructor name `~int' does not match type `<unknown type>' of
expression
error: insufficient contextual information to determine type
3.4.6 silently accepts code and compiles.
Note: author probably meant "top().~T()" :)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32241