From: pavenis AT lanet DOT lv Message-ID: To: "Rob Kramer" , djgpp AT delorie DOT com Date: Thu, 9 Sep 1999 16:54:10 +0300 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: GCC 2.95 global string crashes on 386.. In-reply-to: <199909090422.MAA24404@eastgate.cyberway.com.sg> X-mailer: Pegasus Mail for Win32 (v3.12a) Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk Confirmed with DJGPP ports of egcs-1.1.2 and gcc-2.95.1 (I don't more have gcc-2.95 installed, but that doesn't matter). 2 possible cures: - currently use option '-march=i386' on 386, it should help - in future: I must rebuild gcc-2.95.1 for target i386-pc-msdosdjgpp It took about half a year to found first problem when default were -march=pentium -mcpu=pentium. Even more: it was default for a rather long time in Slackware Linux distribution. Andris On 9 Sep 99, at 12:20, Rob Kramer wrote: > Hi all, > > For some reason using a global STL 'string' crashes my program if run on a > 386 machine. Take the following testcase: > > ----------- > #include > #include > > string foo = "bar"; > > void main() > { > cout << "test: " << foo << endl; > } > ----------- > > Compiled with 'gpp -o test.exe test.cc' (gcc 2.95, bnu 291), this crashes: > > > ----------- > Exiting due to signal SIGILL > Invalid Opcode at eip=00002052 > eax=ffffffff ebx=00021e4c ecx=00021e4c edx=00021e54 esi=00021cdc > edi=00000003 > ebp=000af9dc esp=000af9c4 program=test.exe > cs: sel=00e7 base=10060000 limit=000bffff > ds: sel=00ef base=10060000 limit=000bffff > es: sel=00ef base=10060000 limit=000bffff > fs: sel=00cf base=000391a0 limit=0000ffff > gs: sel=00ff base=00000000 limit=0010ffff > ss: sel=00ef base=10060000 limit=000bffff > App stack: [000afb50..0002fb50] Exceptn stack: [0002fa2c..0002daec] > > Call frame traceback EIPs: > 0x00002052 basic_string, > __default_alloc_template >::Rep::release(void)+18, line 87 of > test.cc > 0x00001e69 basic_string, > __default_alloc_template >::repup(basic_string string_char_traits, __default_alloc_template >::Rep *)+37, > line 147 of test.cc > 0x00001b40 basic_string, > __default_alloc_template >::replace(unsigned long, unsigned long, > char const *, unsigned long)+348, line 168 of test.cc > 0x00002185 basic_string, > __default_alloc_template >::assign(char const *, unsigned > long)+33, line 214 of test.cc > 0x0000209b basic_string, > __default_alloc_template >::assign(char const *)+39, line 216 of > test.cc > 0x00001ef6 basic_string, > __default_alloc_template >::basic_string(char const *)+42, line > 177 of test.cc > 0x00001bff ___static_initialization_and_destruction_0+39, line 7 of test.cc > 0x00002235 global constructors keyed to foo+21, line 3 of test.cc > 0x0001aa35 ___main+53 > 0x00015c75 ___crt1_startup+141 > ----------- > > The test works fine on 486++. Static member-strings won't work either. I > tried to figure out what the SIGILL-invalid opcode was all about, but my fsdb > keeps crashing on my old 386 if I get near the offending part (haven't got full > DJGPP install there). > > This worked on 2.8.1, could someone try to compile this, and see if it works? > > Thanks! > > Rob Kramer > robk AT cyberway DOT com DOT sg > >