gcc заменяет printf с простой строкой на puts.
С -O2 выкидывает куски кода внутри 100%-ложных условий (if (0) {...}).
Круто, чо :-)
test.c:
#include <stdlib.h>
#include <stdio.h>
const int DEBUG = 0;
int main ( int argc, char *argv[] )
{
if (DEBUG) {
printf("Debug!\n");
}
return EXIT_SUCCESS;
}.file "test.c" .globl DEBUG .section .rodata .align 4 .type DEBUG, @object .size DEBUG, 4 DEBUG: .zero 4 .LC0: .string "Debug!" .text .globl main .type main, @function main: leal 4(%esp), %ecx andl $-16, %esp pushl -4(%ecx) pushl %ebp movl %esp, %ebp pushl %ecx subl $4, %esp movl DEBUG, %eax testl %eax, %eax je .L2 subl $12, %esp pushl $.LC0 call puts addl $16, %esp .L2: movl $0, %eax movl -4(%ebp), %ecx leave leal -4(%ecx), %esp ret .size main, .-main .ident "GCC: (GNU) 4.4.4" .section .note.GNU-stack,"",@progbits
.file "test.c" .text .p2align 4,,15 .globl main .type main, @function main: pushl %ebp movl %esp, %ebp xorl %eax, %eax popl %ebp ret .size main, .-main .globl DEBUG .section .rodata .align 4 .type DEBUG, @object .size DEBUG, 4 DEBUG: .zero 4 .ident "GCC: (GNU) 4.4.4" .section .note.GNU-stack,"",@progbits
Проблема со сборкой Кубы (Cuba, http://www.feynarts.de/cuba/)
http://gcc.gnu.org/bugzilla/show_bug.cg