I have attached the full testcase. basically it boils down to enabling any level of optimizations higher than -O1 with -march=i586 or higher. struct matrix { union { struct { float a, b, c, d; float e, f, g, h; float i, j, k, l; float m, n, o, p; } n; float v[16]; float t[4][4]; } data; [...] void identity_bug() { const float I[16] = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; for (int i = 0; i < 16; ++i) data.v[i] = I[i]; } [...] int main() { [...] matrix bug; bug.identity_bug(); [...] } with arch=i486 -O3, the code generated for the indentity_bug() call is: (inlined in main) .LBB36: leal -408(%ebp), %edi cld movl $16, %ecx xorl %eax, %eax rep stosl movl $0x3f800000, -408(%ebp) movl $0x3f800000, -388(%ebp) movl $0x3f800000, -368(%ebp) movl $0x3f800000, -348(%ebp) .loc 1 87 0 .LBB37: but with arch=i586 -O2, the code is: .LBB42: cld leal -392(%ebp), %edi movl $16, %ecx xorl %eax, %eax movl $0x3f800000, -392(%ebp) rep stosl movl $0x3f800000, -372(%ebp) movl $0x3f800000, -352(%ebp) movl $0x3f800000, -332(%ebp) .loc 1 87 0 .LBB43: the second movl gets trashed by the susequent rep stosl. it gets worse with arch=athlon-xp: .LBB38: leal -392(%ebp), %edi movl $16, %ecx xorl %eax, %eax cld movl $0x3f800000, -392(%ebp) movl $0x3f800000, -372(%ebp) movl $0x3f800000, -352(%ebp) rep stosl movl $0x3f800000, -332(%ebp) .loc 1 87 0 .LBB39: now 3 movl get overwritten by the rep stosl. in the test case I also include code for 2x2 and 3x3 matrix. for these the for loop is fully unrolled and is just a sequence of movl, so there is no bug. anybody with a newer gcc knows if this bug is fixed? to test it, untar the attached file, and invoke c.sh. if the result of executing the compiled ./bug is: (last 4 lines) | 0 0 0 0 | | 1 0 0 0 | | 0 1 0 0 | | 0 1 0 0 | | 0 0 1 0 | | 0 0 1 0 | | 0 0 0 1 | | 0 0 0 1 | then your g++ has the bug too. I have tested it with gcc 3.2.1 and it is broken too. a friend tested it on debian testing with gcc 3.2.3 and 3.3 (snapshot 20030415) but they generate the correct code. carlos