c++/2497: g++ can't parse explicit calls to template destructors

anibal@intelerad.com anibal@intelerad.com
Thu Apr 5 13:26:00 GMT 2001


>Number:         2497
>Category:       c++
>Synopsis:       g++ can't parse explicit calls to template destructors
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 05 13:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Anibal Jodorcovsky
>Release:        egcs-2.91.66
>Organization:
>Environment:
Linux RedHat 6.2
>Description:
When trying to call the template destructor explicitly I get:

destructor specifier `vector<basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> >,__default_alloc_template<true,0> >::~vector<basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> >,__default_alloc_template<true,0> >' must have matching names
Hl7Segment.cpp:40: parse error before `>'

From:

    mAl1Fields.~vector<string>();

where mAl1Fields is defined as:

    static vector<string> mAl1Fields;

(even if it's not static it doesn't work).

However, from a 1997 post in a mailing list I got this 
workaround:

typedef vector<string> JJ;

And then calling:

    mAl1Fields.~JJ();

works!

Now, if this problem was found 4 years ago, and this is documented
to work on The C++ Standard Library, A Tutorial And Reference,
by Nicolai M. Josuttis on page 150 4th Edition, I would have
thought that it might have been fixed by now :-)
>How-To-Repeat:
call destructor on a vector, i.e.,

vector<string> myVector;
myVector.~vector<string>();
>Fix:
None available. Workaround possible is the usage of typedef.

typedef vector<string> JJ;

JJ myVector;
myVector.~JJ();
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list