From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16901 invoked by alias); 1 Mar 2011 13:58:09 -0000 Received: (qmail 16892 invoked by uid 22791); 1 Mar 2011 13:58:09 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 01 Mar 2011 13:58:03 +0000 From: "skagget77 at gmail dot com" To: gcc-bugs@gcc.gnu.org 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: skagget77 at gmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Tue, 01 Mar 2011 13:58:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg00075.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47942 --- Comment #4 from Johan Andersson 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(new InlineImpl));