fatal error C1001 with VS2010, boost 1.49, and shared_ptr.hpp

I'm upgrading to boost 1.49 and getting this fatal error while
compiling a source file that uses shared_ptr:
1>C:\mycomps\base\target\dependency\include\boost/smart_ptr/shared_ptr.hpp(362):
fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'msc1.cpp', line 1420)
1> To work around this problem, try simplifying or changing the
program near the locations listed above.
1> Please choose the Technical Support command on the Visual C++
1> Help menu, or open the Technical Support help file for more information
Line 362 of shared_ptr.hpp is:
shared_ptr( shared_ptr<Y> && r, typename
boost::detail::sp_enable_if_convertible

On Mon, Apr 30, 2012 at 10:54 AM, Phillip Hellewell
I'm upgrading to boost 1.49 and getting this fatal error while compiling a source file that uses shared_ptr:
1>C:\mycomps\base\target\dependency\include\boost/smart_ptr/shared_ptr.hpp(362): fatal error C1001: An internal error has occurred in the compiler.
Good news. Luckily I was able to pinpoint the exact line of code causing VS to crash, and two different workarounds: Crashes VS: return Foo_ptr(new Foo()); Workaround 1: return boost::shared_ptr<Foo>(new Foo()); Workaround 2: Foo_ptr ret(new Foo()); return ret; (Foo_ptr is a typedef of boost::shared_ptr<Foo>) Phillip

On Mon, Apr 30, 2012 at 11:14 AM, Phillip Hellewell
Good news. Luckily I was able to pinpoint the exact line of code causing VS to crash, and two different workarounds:
Crashes VS: return Foo_ptr(new Foo());
Workaround 1: return boost::shared_ptr<Foo>(new Foo());
Workaround 2: Foo_ptr ret(new Foo()); return ret;
Oops, I didn't even notice this but the return type on my function is Foo_const_ptr (boost::shared_ptr<const Foo>), not Foo_ptr. So this is the right fix: return Foo_const_ptr(new Foo()); I guess VS gets all flustered when: 1. Converting an r-value shared_ptr to a non-const object, to a shared_ptr to a const object, 2. when typedefs are involved, 3. in Debug x64 (other configurations weren't crashing). There must be some other factors too because when I wrote up a sample 10-line program to illustrate the problem, it didn't crash. Phillip

On Mon, Apr 30, 2012 at 11:56:26AM -0600, Phillip Hellewell wrote:
On Mon, Apr 30, 2012 at 11:14 AM, Phillip Hellewell
wrote: Good news. Luckily I was able to pinpoint the exact line of code causing VS to crash, and two different workarounds:
Crashes VS: return Foo_ptr(new Foo());
Workaround 1: return boost::shared_ptr<Foo>(new Foo());
Workaround 2: Foo_ptr ret(new Foo()); return ret;
Oops, I didn't even notice this but the return type on my function is Foo_const_ptr (boost::shared_ptr<const Foo>), not Foo_ptr.
So this is the right fix: return Foo_const_ptr(new Foo());
I guess VS gets all flustered when: 1. Converting an r-value shared_ptr to a non-const object, to a shared_ptr to a const object, 2. when typedefs are involved, 3. in Debug x64 (other configurations weren't crashing).
There must be some other factors too because when I wrote up a sample 10-line program to illustrate the problem, it didn't crash.
Please file a bug over at Connect [1]. ICEs are never good, especially as this one seems to occur on reasonably well-formed code. [1] http://connect.microsoft.com/VisualStudio -- Lars Viklund | zao@acc.umu.se
participants (2)
-
Lars Viklund
-
Phillip Hellewell