W
WDS
I was compiling some old code with a new compiler and it flagged a
statement as an error. This code compiled (and ran) fine with an
older version of the same compiler. The following snippet
demonstrates:
#include <vector>
void P()
{
std::vector<bool> p;
p.std::~vector<bool>(); // Line 6
}
It that actually valid code? I tried the snippet with various
compilers and here's what I found:
#1: gCC
gCC 3.3.2 accepts it but 3.4.5 complains:
t.C: In function `void P()':
t.C:6: error: `std::~std::vector<bool, std::allocator<bool> >' is not
a member of `std::vector<bool, std::allocator<bool> >'
#2: xlC
AIX xlC older versions accept it but the latest version complains:
"t.C", line 6.24: CZP0157(30) The text ">" is unexpected. It may be
that this token was intended as a template argument list terminator
but the name is not known to be a template.
#3: Visual C++
Both Microsoft Visual 2005 and 2008 C++ complain:
t.cpp(6) : error C2588: '::~vector' : illegal global destructor
statement as an error. This code compiled (and ran) fine with an
older version of the same compiler. The following snippet
demonstrates:
#include <vector>
void P()
{
std::vector<bool> p;
p.std::~vector<bool>(); // Line 6
}
It that actually valid code? I tried the snippet with various
compilers and here's what I found:
#1: gCC
gCC 3.3.2 accepts it but 3.4.5 complains:
t.C: In function `void P()':
t.C:6: error: `std::~std::vector<bool, std::allocator<bool> >' is not
a member of `std::vector<bool, std::allocator<bool> >'
#2: xlC
AIX xlC older versions accept it but the latest version complains:
"t.C", line 6.24: CZP0157(30) The text ">" is unexpected. It may be
that this token was intended as a template argument list terminator
but the name is not known to be a template.
#3: Visual C++
Both Microsoft Visual 2005 and 2008 C++ complain:
t.cpp(6) : error C2588: '::~vector' : illegal global destructor