Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

"foo"=="foo"? OH SHI-

Name: Anonymous 2011-12-12 14:07


haxus_the_great@leetbawx: cat anus.c
int main()
{
  if ("foo" == "foo") {
    return 1;
  } else {
    return 0;
  }
}
haxus_the_great@leetbawx: gcc anus.c -o anus
haxus_the_great@leetbawx: ./anus
haxus_the_great@leetbawx: echo $?
1
haxus_the_great@leetbawx:

U mad? U jelly? Come at me bro.

Name: Anonymous 2011-12-12 16:04


cat t.c
int main()
{
  if ("foo" == "foo") {
    return 1;
  } else {
    return 0;
  }
}

>cat t.s
        .file   "t.c"
        .def    ___main;        .scl    2;      .type   32;     .endef
        .text
        .globl  _main
        .def    _main;  .scl    2;      .type   32;     .endef
_main:
LFB0:
        .cfi_startproc
        pushl   %ebp
        .cfi_def_cfa_offset 8
        .cfi_offset 5, -8
        movl    %esp, %ebp
        .cfi_def_cfa_register 5
        andl    $-16, %esp
        call    ___main
        movl    $1, %eax
        leave
        .cfi_restore 5
        .cfi_def_cfa 4, 4
        ret
        .cfi_endproc
LFE0:


gcc -S is your friend, gcc removed the if statement and just returned 1

>>6
implying gcc compilation is fast to begin with


and no C doesn't compare strings with ==, go back to C++ you moron. == compares pointer values in that case. but as you can see gcc removes it anyway since it knows it'll always return 1

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List