タグ

関連タグで絞り込む (2)

タグの絞り込みを解除

怖いと最適化に関するiwwのブックマーク (1)

  • while(1){LOVE++;}を最適化 - duost

    最近ツイッターで "while(1){LOVE++}"と書き込まれてる指輪があって、 そのソースは最適化でLOVEが消えてただの無限ループになる云々という話があったので検証。 http://togetter.com/li/144840 用意したソースはこちら。 int main() { int LOVE = 0; while(1){LOVE++;} } それじゃアセンブラを見てみましょ。 まずは最適化抜き。 gcc -O0 -s hoge.c .file "hoge.c" .text .globl main .type main, @function main: pushl %ebp movl %esp, %ebp subl $16, %esp movl $0, -4(%ebp) ;LOVE=0 .L2: addl $1, -4(%ebp) ;LOVE++ jmp .L2 ;JUMP TO

    while(1){LOVE++;}を最適化 - duost
    iww
    iww 2011/06/15
    愛の無い無限ループ
  • 1