bug or error in the program

Jinpeng Xie xie@nu.cs.fsu.edu
Wed Sep 30 13:29:00 GMT 1998


Sir,

 	I get a very strange problem. I can not figure out.

I attached testcplus.cpp and README. testcplus reads README line by
line and store it in char **array, then  outputs char **array to
to screen. I run g++ -o testcplus testcplus.cpp to compile it.

I use "array = new char *();" to allocate memory first,
for each line, I use "array[i] = new char[length]" to allocate memory.

1. testcplus.cpp can run on Solaris 2.6 after compiling by g++.
   I cited the output from g++ -v from Solaris 2.6 as follows:
   Reading specs from 
   /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/specs
   gcc version 2.8.1

2. if testcplus.cpp run on Redhat 4.2, first few lines of output are
garbage, then we can  get expected outputs. Finally it goes to crash.
I cited the last few lines of output as follows:

==========================================================================
Use the script 'cleanlog' to remove these files.  'cleanlog'
also checks for core files.
------------------------------------------------------------------


Program received signal SIGSEGV, Segmentation fault.
0x400ac49d in __libc_free ()
(gdb) where
#0  0x400ac49d in __libc_free ()
#1  0x4003b814 in __DTOR_END__ ()
#2  0x8052488 in ?? ()
#3  0x656d616e in ?? ()
Cannot access memory at address 0x656c6966.
=========================================================================

 RedHat 4.2 have installed 2.7.2.1 g++. Output of g++ -v is given as
follows:

Reading specs from /usr/lib/gcc-lib/i386-linux/2.7.2.1/specs
gcc version 2.7.2.1

3. testcplus can not run on Redhat 5.1 after I updated g++ to egcs 1.1
release [Reading specs from
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)].

or before I updated [old version is: Reading specs from
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.27/specs
gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)].

However, after I truncate README to 25 lines, testcplus runs very well.



--Jinpeng

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
*                                                                  *
*Jinpeng  Xie                   Office Phone:(850)-487-0054        *
*Dept. of Computer Science      Office: Dept. of Management Service*
*Florida State University       E-mail: xie@cs.fsu.edu             *
*                                                                  *
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*


More information about the Gcc-bugs mailing list