Segmentation faulty code from egcs-1998-05-25

Petter Urkedal petter@matfys.lth.se
Sat May 30 09:00:00 GMT 1998


The following code compiles to an exectable which gives a segmentation
fault.  I am rather well convinced that the code is valid C++.  If
you need more info, please mail me (but I will be away until June 18).

Sincerly,
Petter.

----------------seg_fault.cc--------------------------------------------
class v_base {
    int ic;
public:
    v_base() : ic(0) {}
    virtual void obscure() { --ic; }
};

struct base { int i; };

struct foo : public base, virtual public v_base {
    virtual void vmf() {}
};

main() {
    foo *fp = new foo;
    fp->obscure();
    delete fp;
    fp = new foo;   // This line is "set_fault.cc:19"
}
------------version+platform---------------------------------------------

[petter@katsumoto slot]$ g++ -v
Reading specs from
/usr/local/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.91.33/specs
gcc version egcs-2.91.33 19980525 (gcc2 ss-980502 experimental)

---------------compilation----------------------------------------------

[petter@katsumoto slot]$ g++ -g seg_fault.cc
[petter@katsumoto slot]$ a.out
Segmentation fault (core dumped)     [independent of -g option]

----------------backtrace-----------------------------------------------

[petter@katsumoto slot]$ gdb a.out core
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for
details.
GDB 4.16 (i386-redhat-linux), Copyright 1996 Free Software Foundation,
Inc...
Core was generated by `a.out'.
Program terminated with signal 11, Segmentation fault.
find_solib: Can't read pathname for load map: Input/output error

#0  0x40064e36 in ?? () from /lib/libc.so.6
(gdb) bt
#0  0x40064e36 in ?? () from /lib/libc.so.6
#1  0x400bbf94 in ?? () from /lib/libc.so.6
#2  0x4006452a in ?? () from /lib/libc.so.6
#3  0x40064b75 in ?? () from /lib/libc.so.6
#4  0x40064605 in ?? () from /lib/libc.so.6
#5  0x804af1a in __builtin_new (sz=12)
#6  0x8049155 in main () at seg_fault.cc:19

-- 

[- http://matfys.lth.se/~petter/ -]



More information about the Gcc-bugs mailing list