Bug 49450 - not possible to call explicit destructor of std::string
Summary: not possible to call explicit destructor of std::string
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-17 11:03 UTC by Johnny Willemsen
Modified: 2011-06-17 13:39 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johnny Willemsen 2011-06-17 11:03:23 UTC
We want to use C++0x unions with a std::string as member (see for example http://www2.research.att.com/~bs/C++0xFAQ.html#unions). At the moment we want to call the ~string we get an error.

Reproducer:

#include <string>

int main ()
{
        std::string s;
        s.~string();
        return 0;
}

message

g++-4.6 -c t.cpp
t.cpp: In function ‘int main()’:
t.cpp:6:11: error: expected class-name before ‘(’ token
Comment 1 Johnny Willemsen 2011-06-17 11:32:51 UTC
g++-4.6 (SUSE Linux) 4.6.0 20110505 [gcc-4_6-branch revision 173419]
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Comment 2 Daniel Krügler 2011-06-17 13:32:44 UTC
(In reply to comment #0)
> We want to use C++0x unions with a std::string as member (see for example
> http://www2.research.att.com/~bs/C++0xFAQ.html#unions). At the moment we want
> to call the ~string we get an error.

Your program is not conforming according to the standard. You need to write

s.std::string::~string();

instead.
Comment 3 Johnny Willemsen 2011-06-17 13:34:58 UTC
user error
Comment 4 Johnny Willemsen 2011-06-17 13:39:20 UTC
correct status