|
Boost : |
From: Jason Shirk (jasonsh_at_[hidden])
Date: 2001-07-11 01:34:53
This looks like a problem with the explicit constructor in shared_ptr.
Explicit didn't work very well in VC6. It correctly fails to compile
with VC7 Beta2.
Your second example gives an error with VC7 Beta2. If you get rid of
the explicit specialization, then it compiles without error and
generates correct code. I'm not sure if the error is a bug or not. I
have several compilers that can't agree on explicit specializations
defined inside a class.
Now that we have shipped VC7 Beta2, I recommend upgrading if possible.
You'll get a much better compiler than VC6. I am disappointed we
couldn't get as much conformance work in as we would have liked.
However, I am pretty sure our first release after VC7 will address most
conformance concerns. (And sorry, I have absolutely no idea when that
release will happen.)
Jason Shirk
VC++ Compiler Team
-----Original Message-----
From: mred_at_[hidden] [mailto:mred_at_[hidden]]
Sent: Monday, July 09, 2001 6:48 PM
To: boost_at_[hidden]
Subject: [boost] MSVC++ bug with share_ptr
I really wanted the templated shared_ptr assignment and constructor
turned on for MSVC++ 6.0 in this latest boost release. But in the
following program, MSVC++ 6.0 SP5 skips right over the first
assignment to share_ptr! (It does not emit assembly for it.)
Should MSVC++ fail to compile the first assignment, or should it
automatically instantiate "shared_ptr<int>"?
Even scarier, you can add "p = new char;" and it compiles.
-Ed-
-=-=-=-=-
#include <boost/smart_ptr.hpp>
#include <iostream>
template <typename T>
struct A {
A( int ) {}
template <typename U> A<T>& operator = (const A<U>& that) {
std::cout << "works" << std::endl;
return *this;
}
template <> A<T>& operator = (const A<T>& that) {
std::cout << "works" << std::endl;
return *this;
}
};
int main() {
boost::shared_ptr<int> p;
p = new int; // MSVC++ 6.0 will skip this line!
p = boost::shared_ptr<int>(new int); // will work
A<int> q(0);
q = A<int>(1); // will work
q = A<char>(1); // will work
q = int(); // MSVC++ 6.0 will skip this line!
q = char(); // MSVC++ 6.0 will skip this line!
return 0;
}
Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk