Hi all, I’m trying to use the __attribute__((optimize(“-O2”))) to mark a function that should always be optimized. But it doesn’t seem to work. I’ve tested both GCC 4.9.2 and 4.8.3, they both silently ignored the attribute. I’m wondering if I’m something super stupid that I’m not aware of. Please see the small test program below. $ cat t.c #include <stdio.h> int foo() { return 2; } int main(int argc, const char *argv[]) { printf("%d\n", foo()); return 0; } $ gcc t.c $ gdb a.out (gdb) disas foo Dump of assembler code for function foo: 0x0000000000400506 <+0>: push %rbp 0x0000000000400507 <+1>: mov %rsp,%rbp 0x000000000040050a <+4>: mov $0x2,%eax 0x000000000040050f <+9>: pop %rbp 0x0000000000400510 <+10>: retq End of assembler dump. (gdb) q $ gcc t.c -O2 $ gdb a.out (gdb) disas foo Dump of assembler code for function foo: 0x0000000000400530 <+0>: mov $0x2,%eax 0x0000000000400535 <+5>: retq End of assembler dump. (gdb) q $ cat t.c #include <stdio.h> int foo() __attribute__((optimize("-O2"))); int foo() { return 2; } int main(int argc, const char *argv[]) { printf("%d\n", foo()); return 0; } $ gcc t.c $ gdb a.out (gdb) disas foo Dump of assembler code for function foo: 0x0000000000400506 <+0>: push %rbp 0x0000000000400507 <+1>: mov $0x2,%eax 0x000000000040050c <+6>: mov %rsp,%rbp 0x000000000040050f <+9>: pop %rbp 0x0000000000400510 <+10>: retq End of assembler dump. Thanks, Chaoran