From: s5muma AT rz DOT uni-jena DOT de (Marc Mueller) Newsgroups: comp.os.msdos.djgpp Subject: GCC optimization option "-O3" buggy ? Date: 3 Mar 1997 20:03:56 GMT Organization: Friedrich-Schiller-University Jena, Germany Lines: 124 Message-ID: <5ffarc$l0t@fsuj19.rz.uni-jena.de> NNTP-Posting-Host: fsuj80.rz.uni-jena.de To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hi, I wrote a small program to test o2c, a converter for TASM-like .OBJ files. Compiling the C-source with optimization flag "-O3" causes general protection faults in runtime, otherwise all runs quite right. First the source : --------------------------------------ASMTEST.ASM (written for TASM, convert .OBJ file using o2c) .386 .MODEL USE32 FLAT, C .CODE PUBLIC _asmtst _asmtst PROC // should fill a array of int's ARG intarray : PTR DWORD, arraysize : DWORD cld push ds pop es mov edi, [intarray] mov ecx, [arraysize] xor eax,eax @@LP: stosd inc eax loop @@LP ret _asmtst ENDP END ----------------------------------------End of ASMTEST.ASM ----------------------------------------ASMTEST.C #include #include #include extern void _asmtst( int *intarray, int arraysize ); int main( void ) { int *p1, *p0, h, arsize = 15000000; // ----- Allocate array if ( !( p1 = p0 = malloc( arsize * sizeof(int) ) ) ) { exit( -1 ); } // ----- Fill array asm printf( "fill array asm\n" ); _asmtst( p0, arsize ); // ----- Fill array C printf( "fill array C\n" ); for ( h=0; ( h