Undesirable STL Compile Breaking Change in RC

The following code will compile in VC++ 2003 but not VC++ 2005 RC:

#include <windows.h>
#include <atlbase.h>
#include <list>

int _tmain(int argc, _TCHAR* argv[])
{
   std::list<CComPtr<IUnknown> > l;
   l.insert(l.begin(), CComPtr<IUnknown>());
   return 0;
}

S
hould line #1163 of #include <list> be changed from:

this->_Alval.construct(&_Myval(_Pnode), _Val);

to something like:

this->_Alval.construct(reinterpret_cast<_Ty*>(&reinterpret_cast<unsigned char&>(_Myval(_Pnode))), _Val);

As it is currently coded, any class that implements operator&() has a good chance of failing to compile and thus be impossible to serve as an element of a list (or any other STL container that utilizes a list):

For example, the following will also fail:

class A
{
public:
   A() {}
   int* operator&() const { return p; }
private:
   int*   p;
};

void f()
{
   std::list<A> l;
   A a;
   l.insert(l.begin(), a);
}



Answer this question

Undesirable STL Compile Breaking Change in RC