This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/47942] Not possible to initialize a shared_ptr with a class defined in function scope, inheriting from a global scope base class
- From: "skagget77 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 1 Mar 2011 13:58:02 +0000
- Subject: [Bug c++/47942] Not possible to initialize a shared_ptr with a class defined in function scope, inheriting from a global scope base class
- Auto-submitted: auto-generated
- References: <bug-47942-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47942
--- Comment #4 from Johan Andersson <skagget77 at gmail dot com> 2011-03-01 13:58:00 UTC ---
Thanks for the quick reply and advice to use static_cast, the reinterpret_cast
was a temporary memory lapse!
The old GCC version was because I used a web-interface to verify the problem.
I'm normally on Windows and Visual C++.
(In reply to comment #3)
> (In reply to comment #2)
> > Your options are either to use C++0x mode (classes without linkage can be used
> > as template arguments in C++0x) or to upcast the pointer
>
> It seems that the change to allow local types as template args (see
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm for the
> proposal) was implemented in GCC 4.5, so you can't rely on that in 4.4
>
> So the best option is:
>
> return BasePtr(static_cast<Base*>(new InlineImpl));