* problem with exception handling
@ 1997-10-17 14:36 Heinrich Roder
1997-10-17 19:31 ` H.J. Lu
1997-11-01 22:07 ` Jeffrey A Law
0 siblings, 2 replies; 3+ messages in thread
From: Heinrich Roder @ 1997-10-17 14:36 UTC (permalink / raw)
To: egcs
[-- Attachment #1: Type: text/plain, Size: 3180 bytes --]
Why do I get a dumped core in this program. I use
the newest snapshot installed, ( test.C is attached)
gdb gives the following
Breakpoint 1 at 0x4002aba4
-- main starts --
-- f1 starts --
L TraceLifetime constructed for a.
-- f2 starts --
LL TraceLifetime constructed for c.
LD TraceLifetime destroyed for c.
Breakpoint 1, 0x4002aba4 in abort ()
(gdb) where
#0 0x4002aba4 in abort ()
#1 0x8050029 in copy_reg (reg=16, udata=0xbffff894, target_udata=0xbffff824)
#2 0x80502b1 in __throw ()
#3 0x804a304 in f1 () at /home/hro/C++/test.C:58
#4 0x804a3e9 in main () at /home/hro/C++/test.C:66
#5 0x804a02b in _start ()
--------------------------
1067> g++ -v -o ff ~/C++/test.C
Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.13/specs
gcc version egcs-2.90.13 971016 (gcc2-970802 experimental)
/usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.13/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Di386 -Di586 -Asystem(unix) -Acpu(i386) -Amachine(i386) -D__i386__ -D__i586__ -Asystem(unix) -Acpu(i386) -Amachine(i386) /home/hro/C++/test.C /tmp/cca21366.ii
GNU CPP version egcs-2.90.13 971016 (gcc2-970802 experimental) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include/g++
/usr/local/include
/usr/local/i586-pc-linux-gnulibc1/include
/usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.13/include
/usr/include
End of search list.
/usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.13/cc1plus /tmp/cca21366.ii -quiet -dumpbase test.cc -version -o /tmp/cca21366.s
GNU C++ version egcs-2.90.13 971016 (gcc2-970802 experimental) (i586-pc-linux-gnulibc1) compiled by GNU C version 2.7.2.3.f.1.
/usr/local/include/g++/iostream.h: In method `int ostream::opfx()':
In file included from /home/hro/C++/test.C:18:
/usr/local/include/g++/iostream.h:53: warning: implicit declaration of function `int _IO_flockfile(...)'
/usr/local/include/g++/iostream.h: In method `void ostream::osfx()':
/usr/local/include/g++/iostream.h:54: warning: implicit declaration of function `int _IO_funlockfile(...)'
as -V -Qy -o /tmp/cca213661.o /tmp/cca21366.s
GNU assembler version 2.7 (i586-unknown-linux), using BFD version 2.7.0.2
/usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.13/ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.1 -o ff /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.13/crtbegin.o -L/usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.13 -L/usr/local/i586-pc-linux-gnulibc1/lib -L/usr/local/lib /tmp/cca213661.o -lstdc++ -lm -lgcc -lc -lgcc /usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.13/crtend.o /usr/lib/crtn.o
|11:51:08 :hro at barney> , ~/oldhome/scratch/egcs-971016/gcc :
1068> ff
-- main starts --
-- f1 starts --
L TraceLifetime constructed for a.
-- f2 starts --
LL TraceLifetime constructed for c.
LD TraceLifetime destroyed for c.
LD TraceLifetime destroyed for c.
IOT trap/Abort (core dumped)
thanks for any help.
HEinrich
--
test.C
[-- Attachment #2: test.C --]
[-- Type: text/x-c++, Size: 2145 bytes --]
class TraceLifetime {
public:
TraceLifetime(const char* variable_name); // Create and print message.
~TraceLifetime(); // Destroy and print message.
private:
enum { max_objects_to_trace = 100 }; // Maximum number of objects to trace
static char existing_objects[1+max_objects_to_trace]; // L = live; D = destroyed.
static int total_created;
int instance_number; // Creation sequence number.
char var_name[21]; // Name of variable (first 20 chars + null)
// This should be String, but I get an internal compiler error message when using String
};
#include <string.h>
#include <iostream.h>
int TraceLifetime::total_created = 0;
char TraceLifetime::existing_objects[1+TraceLifetime::max_objects_to_trace] = "";
TraceLifetime::TraceLifetime(const char* variable_name) :
instance_number(total_created++) {
// Copy first 20 characters of variable name
strncpy(var_name, variable_name, 20);
var_name[20] = '\0';
if (total_created <= max_objects_to_trace) {
existing_objects[total_created-1] = 'L';
existing_objects[total_created] = '\0';
cout << existing_objects << " TraceLifetime constructed for " << var_name << "." << endl;
}
}
TraceLifetime::~TraceLifetime() {
if (instance_number < max_objects_to_trace) {
existing_objects[instance_number] = 'D';
cout << existing_objects << " TraceLifetime destroyed for " << var_name << "." << endl;
}
}
//main routines start here
void f2() {
cout << "-- f2 starts -- " << endl;
TraceLifetime c("c");
throw "exception";
cout << "-- f2 ends -- " << endl;
}
void f1() {
cout << "-- f1 starts -- " << endl;
TraceLifetime a("a");
f2();
TraceLifetime b("b");
cout << "-- f1 ends -- " << endl;
}
int main() {
cout << "-- main starts --" << endl;
try {
f1();
}
catch(const char* dd) {
cout << "Exception caught." <<dd<< endl;
}
cout << "-- main ends --" << endl;
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: problem with exception handling
1997-10-17 14:36 problem with exception handling Heinrich Roder
@ 1997-10-17 19:31 ` H.J. Lu
1997-11-01 22:07 ` Jeffrey A Law
1 sibling, 0 replies; 3+ messages in thread
From: H.J. Lu @ 1997-10-17 19:31 UTC (permalink / raw)
To: Heinrich Roder; +Cc: egcs
>
>
> --C0X6iWwYi9OgoVx8GtiA8gVni+RCEOFHDcBlzx9W
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> Why do I get a dumped core in this program. I use
> the newest snapshot installed, ( test.C is attached)
>
> gdb gives the following
> Breakpoint 1 at 0x4002aba4
> -- main starts --
> -- f1 starts --
> L TraceLifetime constructed for a.
> -- f2 starts --
> LL TraceLifetime constructed for c.
> LD TraceLifetime destroyed for c.
>
> Breakpoint 1, 0x4002aba4 in abort ()
I have no problems on linux/x86 libc 5.4.39.
H.J.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: problem with exception handling
1997-10-17 14:36 problem with exception handling Heinrich Roder
1997-10-17 19:31 ` H.J. Lu
@ 1997-11-01 22:07 ` Jeffrey A Law
1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey A Law @ 1997-11-01 22:07 UTC (permalink / raw)
To: Heinrich Roder; +Cc: egcs
In message <199710171756.LAA21622@barney.lanl.gov>you write:
>
> --C0X6iWwYi9OgoVx8GtiA8gVni+RCEOFHDcBlzx9W
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> Why do I get a dumped core in this program. I use
> the newest snapshot installed, ( test.C is attached)
>
> gdb gives the following
> Breakpoint 1 at 0x4002aba4
> -- main starts --
> -- f1 starts --
> L TraceLifetime constructed for a.
> -- f2 starts --
> LL TraceLifetime constructed for c.
> LD TraceLifetime destroyed for c.
>
> Breakpoint 1, 0x4002aba4 in abort ()
> (gdb) where
> #0 0x4002aba4 in abort ()
> #1 0x8050029 in copy_reg (reg=16, udata=0xbffff894, target_udata=0xbffff82
> 4)
> #2 0x80502b1 in __throw ()
> #3 0x804a304 in f1 () at /home/hro/C++/test.C:58
> #4 0x804a3e9 in main () at /home/hro/C++/test.C:66
> #5 0x804a02b in _start ()
> --------------------------
Your testcase works for me using the current sources; you should
try it after I make the next snapshot.
jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1997-11-01 22:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-17 14:36 problem with exception handling Heinrich Roder
1997-10-17 19:31 ` H.J. Lu
1997-11-01 22:07 ` Jeffrey A Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).