Message-Id: <199909090422.MAA24404@eastgate.cyberway.com.sg> From: "Rob Kramer" To: djgpp AT delorie DOT com Date: Thu, 9 Sep 1999 12:20:58 +0800 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: GCC 2.95 global string crashes on 386.. X-mailer: Pegasus Mail for Win32 (v3.01b) Reply-To: djgpp AT delorie DOT com 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, __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