Thread View: de.comp.gnu
2 messages
2 total messages
Started by Bjoern Dosch
Sun, 15 Oct 1995 15:58
Problem mit RTTI und gcc/libg++ 2.7.0
Author: Bjoern Dosch
Date: Sun, 15 Oct 1995 15:58
Date: Sun, 15 Oct 1995 15:58
53 lines
1926 bytes
1926 bytes
Hallo!
Ich habe hier ein Problem mit RTTI unter dem gcc 2.7.0/libg++
2.7.0. Folgendes Programm stürzt kläglich ab, wenn es mit
-handle-exceptions und -frtti kompiliert wurde:
01: #include <std/typeinfo.h>
02:
03: #include <iostream.h>
04: #include <fstream.h>
05:
06: int main ()
07: {
08: ifstream stream ("/etc/passwd");
09:
10: if (! stream.ios::good ())
11: {
12: cerr << "Error\n";
13: exit (1);
14: }
15: char str[128] = "";
16: stream.getline (str, 128);
17: }
Program received signal SIGSEGV (11), Segmentation fault
0x1f34c in istream::getline (this=0xeffff93c, buf=0xeffff868 "", len=128,
delim=10 '\n') at isgetline.cc:38
Ein Stack-Backtrace ergibt
(gdb) bt
#0 0x1f34c in istream::getline (this=0xeffff93c, buf=0xeffff868 "", len=128,
delim=10 '\n') at isgetline.cc:38
#1 0x183b4 in main () at test.cc:16
isgetline.cc:38 sieht so aus:
if (ipfx1())
ipfx1() ist eine "normale" inline-Funktion (in der Klassendefinition
von istream ->libg++-2.7.0/libio/iostream.h).
Ohne -handle-exceptions und -frtti gibt es keine Probleme.
Ist so ein Verhalten jemandem bekannt? Liegt das an dem alpha
RTTI-Code? (Ich würde ihn ja nicht benutzen, aber ohne RTTI
funktioniert auch das Exception-Handling nicht vernünftig...)
Ciao
--
Björn Dosch
Usenet: bjd@charon.tauber.netz.sub.de
-- PGP Public Key Available --
Re: Problem mit RTTI und gcc/libg++ 2.7.0
Author: Ralf W. Stephan
Date: Mon, 16 Oct 1995 11:17
Date: Mon, 16 Oct 1995 11:17
49 lines
2349 bytes
2349 bytes
Bjoern Dosch writes:
> (gdb) bt
> #0 0x1f34c in istream::getline (this=0xeffff93c, buf=0xeffff868 "", len=128,
> delim=10 '\n') at isgetline.cc:38
> #1 0x183b4 in main () at test.cc:16
Dazu passend ein Artikel aus gnu.g++.help:
From: bashford@toad.scripps.edu (Don &)
Subject: Re: Run Time Type Identification
Date: 12 Oct 1995 05:22:15 GMT
Message-ID: <BASHFORD.95Oct11222215@toad.scripps.edu>
>>>>> "Alex" == Alex Martelli <martelli@cadlab.cadlab.it> writes:
Alex> douvilld@Cognos.COM (Derek Douville) writes:
>> I would like to know if the latest version of the Gnu g++
>> compiler supports RTTI (i.e. typeid() and before() etc). If I
>> include <typeinfo.h> and use one of these functions, I get a
>> "not supported" message. I am running gnu v 2.6.2.
Alex> Should work fine with g++ 2.7.0, compiling with -frtti of
Alex> course.
Well, sort of. RTTI is still an "alpha" feature of g++.
First of all you must include <typeinfo> not <typeinfo.h>.
ALL of the files that you link together must by compiled with -frtti
and must include <typeinfo> whether they use RTTI or not. In
principle, even libg++ must be compiled this way (see the g++ FAQ).
However, I have found that code of mine that uses just the
String class and cin, cout and cerr works okay even though my
libg++ is not compiled with RTTI. I can't use fstreams or
strstreams though (compiles and links but dumps core).
Within the above limitations, I have found that RTTI works
pretty much as I expected to. In a "toy" implementation I
have been able to use to implement multi-methods and virtual
constructors in a much nicer way than I could before.
By the way, do any of the g++ maintainers know if the next version
(2.7.1?) will lift some of these limitations?
Don Bashford
bashford@scripps.edu
ralf
--
PGP: 1024/0xA713ECE9 2047/0xC8E605F5
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads