Bug 42019 - shared_ptr can not be used with -fno-rtti
Summary: shared_ptr can not be used with -fno-rtti
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Jonathan Wakely
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-12 14:27 UTC by tom.deseyn
Modified: 2009-11-20 21:26 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2009-11-12 17:03:49


Attachments
proposed patch (1.88 KB, patch)
2009-11-18 01:30 UTC, Jonathan Wakely
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tom.deseyn 2009-11-12 14:27:01 UTC
The shared_ptr implementation uses typeid and therefore fails to compile with -fno-rtti.

Perhaps the functionality can be reduced by #ifdef __GCC_RTTI?

testcase:

#include <tr1/memory>

using namespace std::tr1;

class A {};

int main()
{
	shared_ptr<A> spA;
}


gcc info:
g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/gcctrunk/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/tom/svn/gcc/configure --prefix=/opt/gcctrunk --disable-sjlj-exceptions : (reconfigured) /home/tom/svn/gcc/configure --prefix=/opt/gcctrunk --disable-sjlj-exceptions
Thread model: posix
gcc version 4.5.0 20091105 (experimental) (GCC)
Comment 1 Jonathan Wakely 2009-11-12 17:03:49 UTC
Seems like a reasonable request, it will disable at least the get_deleter() functionality.  I'll work on this when I update shared_ptr to match the latest WP
Comment 2 Jonathan Wakely 2009-11-18 01:30:51 UTC
Created attachment 19031 [details]
proposed patch

I'm testing this, with and without -fno-rtti

Without rtti 20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc fails as expected
Comment 3 Jonathan Wakely 2009-11-20 21:23:22 UTC
Subject: Bug 42019

Author: redi
Date: Fri Nov 20 21:23:02 2009
New Revision: 154377

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154377
Log:
2009-11-20  Jonathan Wakely  <jwakely.gcc@gmail.com>

	PR libstdc++/42019
	* include/tr1/shared_ptr.h: Only use typeid when RTTI is enabled.
	* include/bits/shared_ptr_base.h: Likewise.
	* include/bits/shared_ptr.h: Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/misc/42019.cc: New.
	* testsuite/20_util/shared_ptr/misc/42019.cc: New.


Added:
    trunk/libstdc++-v3/testsuite/20_util/shared_ptr/misc/42019.cc
    trunk/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/misc/42019.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/shared_ptr.h
    trunk/libstdc++-v3/include/bits/shared_ptr_base.h
    trunk/libstdc++-v3/include/tr1/shared_ptr.h

Comment 4 Jonathan Wakely 2009-11-20 21:26:12 UTC
Fixed for 4.5.0