Does the compiler have the equivalent of -S in GCC?
Code:
$ cat foo.c
#include<stdio.h>
long int a = 99;
long int b = 42;
void foo()
{
long int c = a * b;
printf("%ld\n",c);
}
$ gcc -S -c foo.c
$ cat foo.s
.file "foo.c"
.globl a
.data
.align 8
.type a, @object
.size a, 8
a:
.quad 99
.globl b
.align 8
.type b, @object
.size b, 8
b:
.quad 42
.section .rodata
.LC0:
.string "%ld\n"
.text
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
movq %rsp, %rbp
.cfi_offset 6, -16
.cfi_def_cfa_register 6
subq $16, %rsp
movq a(%rip), %rdx
movq b(%rip), %rax
imulq %rdx, %rax
movq %rax, -8(%rbp)
movl $.LC0, %eax
movq -8(%rbp), %rdx
movq %rdx, %rsi
movq %rax, %rdi
movl $0, %eax
call printf
leave
ret
.cfi_endproc
.LFE0:
.size foo, .-foo
.ident "GCC: (Ubuntu 4.4.3-4ubuntu5) 4.4.3"
.section .note.GNU-stack,"",@progbits
If you can create a pair of functions with the offending line, one which works and the other doesn't, then you have something pretty solid for a potential bug report.
But the real test would be to go through the generated assembler to see what is really going on.
Really small code samples make this a relatively easy prospect.