Hi, I try the following code:
#define MAX_N 40 #define MAX_R 25 #ifndef FALSE #define FALSE 0 #define TRUE 1 #endif static unsigned int bin_coeff_tab[ MAX_N ][ MAX_R ]; static int is_calculated = FALSE; static void bin_coeff_init( void ) { int i, j; for( i = 0; i < MAX_N; i++ ) bin_coeff_tab[ i ][ 0 ] = i + 1; for( j = 1; j < MAX_R; j++ ) bin_coeff_tab[ 0 ][ j ] = 0; for( i = 1; i < MAX_N; i++ ) for( j = 1; j < MAX_R; j++ ) bin_coeff_tab[ i ][ j ] = bin_coeff_tab[ i - 1 ][ j - 1 ] + bin_coeff_tab[ i - 1 ][ j ]; is_calculated = TRUE; } int main() { bin_coeff_init(); return 0; } (There is no header file included, so I won't include the .i file) If I try to compile this with both -O3 and -msse, I get a segmentation fault. > gcc --version gcc (GCC) 4.3.0 20080305 (alpha-testing) mingw-20080502 the assembler code file becomes: .file "mytest.c" .def ___main; .scl 2; .type 32; .endef .text .p2align 2,,3 .globl _main .def _main; .scl 2; .type 32; .endef _main: leal 4(%esp), %ecx andl $-16, %esp pushl -4(%ecx) pushl %ebp movl %esp, %ebp pushl %esi pushl %ebx pushl %ecx subl $12, %esp call ___main movl $_bin_coeff_tab, %edx xorl %eax, %eax .p2align 2,,3 L2: incl %eax movl %eax, (%edx) addl $100, %edx cmpl $40, %eax jne L2 movl $0, _bin_coeff_tab+4 movl $0, _bin_coeff_tab+8 movl $0, _bin_coeff_tab+12 xorps %xmm0, %xmm0 movaps %xmm0, _bin_coeff_tab+16 movaps %xmm0, _bin_coeff_tab+32 movaps %xmm0, _bin_coeff_tab+48 movaps %xmm0, _bin_coeff_tab+64 movaps %xmm0, _bin_coeff_tab+80 movl $0, _bin_coeff_tab+96 movl $1, %esi .p2align 2,,3 L3: leal (%esi,%esi,4), %eax leal (%eax,%eax,4), %eax leal _bin_coeff_tab-100(,%eax,4), %edx leal _bin_coeff_tab+4(,%eax,4), %ebx movl $1, %ecx .p2align 2,,3 L4: movl 4(%edx), %eax addl (%edx), %eax movl %eax, (%ebx) incl %ecx addl $4, %edx addl $4, %ebx cmpl $25, %ecx jne L4 incl %esi cmpl $40, %esi jne L3 movl $1, _is_calculated xorl %eax, %eax addl $12, %esp popl %ecx popl %ebx popl %esi leave leal -4(%ecx), %esp ret .lcomm _is_calculated,16 .lcomm _bin_coeff_tab,4000 Best regards, -Øystein -- Summary: options -O3 and -msse does not cooperate ? Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: oystein at gnubg dot org GCC host triplet: windows (mingw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39194