00291838mov dword ptr ,31h
if('a' <= ch <= 'z') printf("hello\n");
0029183Fcmp dword ptr ,61h
00291843jl main+41h (0291851h)
00291845mov dword ptr ,1
0029184Fjmp main+4Bh (029185Bh)
00291851mov dword ptr ,0
0029185Bcmp dword ptr ,7Ah
00291862jg main+61h (0291871h)
00291864push offset string "hello\n" (0297B30h)
00291869call _printf (0291046h)
0029186Eadd esp,4
在gcc中直接优化掉了这个判断,因为永远为真,没有判断的必要
.file "main.c"
.text
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "hello\0"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $49, 28(%esp)
movl $LC0, (%esp)
call _puts
movl $0, %eax
leave
ret
.ident "GCC: (GNU) 7.4.0"
.def _puts; .scl 2; .type 32; .endef
#include <stdio.h>
#include <string.h>
int main(void)
{
int ch = '1';
if('a' <= ch <= 'z') printf("hello\n");
return 0;
}
TCY 发表于 2020-3-6 16:49
那为什么不报错?
我回复了两个,下一页还有一个
页:
1
[2]