楼主的问题:
int main(void)
{
4004e4: 55 push %rbp
4004e5: 48 89 e5 mov %rsp,%rbp
if(0 && 1 || 1)
;
return 0;
4004e8: b8 00 00 00 00 mov $0x0,%eax
}
4004ed: 5d pop %rbp
4004ee: c3 retq
gcc -O0编译都会直接优化掉,无法测试,所以我弄了几个volatile变量来测试:
int main(void)
{
4004e4: 55 push %rbp
4004e5: 48 89 e5 mov %rsp,%rbp
volatile int a = 0;
4004e8: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
volatile int b = 1;
4004ef: c7 45 f8 01 00 00 00 movl $0x1,-0x8(%rbp)
volatile int c = 1;
4004f6: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%rbp)
volatile int d = -1;
4004fd: c7 45 f0 ff ff ff ff movl $0xffffffff,-0x10(%rbp)
if(a && b || c)
400504: 8b 45 fc mov -0x4(%rbp),%eax
400507: 85 c0 test %eax,%eax
400509: 74 07 je 400512 <main+0x2e>
//如果a为0 跳转到400512测试c
40050b: 8b 45 f8 mov -0x8(%rbp),%eax
40050e: 85 c0 test %eax,%eax
400510: 75 07 jne 400519 <main+0x35>
//如果b不为0,直接执行++d
400512: 8b 45 f4 mov -0xc(%rbp),%eax
400515: 85 c0 test %eax,%eax
400517: 74 09 je 400522 <main+0x3e>
//如果c为0,跳出,不会执行++d
++d;
400519: 8b 45 f0 mov -0x10(%rbp),%eax
40051c: 83 c0 01 add $0x1,%eax
40051f: 89 45 f0 mov %eax,-0x10(%rbp)
return 0;
400522: b8 00 00 00 00 mov $0x0,%eax
}
综上所述,楼主的问题是存在的
怕百度把代码弄乱套,所以传到codepad上:
http://codepad.org/TEJxaoe7