サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
iPhone 17
qiita.com/fujitanozomu
はじめに gccの最適化指示である-Ofastをお気軽に使ってる記事を見掛けたので注意喚起的なやつです。 -Ofastとは何ぞや gccのドキュメントから引用 https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-Ofast -Ofast Disregard strict standards compliance. -Ofast enables all -O3 optimizations. It also enables optimizations that are not valid for all standard-compliant programs. It turns on -ffast-math, -fallow-store-data-races and the Fortran-specific -fstac
#include <stdio.h> void fizzbuzz(int n) { int next; int i = 1; do { printf(i % 15 ? i % 5 ? i % 3 ? "%d\n" : "Fizz\n" : "Buzz\n" : "FizzBuzz\n", i); if (i++ >= n) next = 0; } while (next); } int main(void) { printf((char[]){""}); // この位置にprintfが無いとなぜか動かない fizzbuzz(100); } gcc 10.1.0 を使用し、コンパイラが感知したミスには警告を出力してくれる様 -Wall -Wextra を指定し、最適化指示なしでコンパイル、動作させたところ動作するが Wandboxで実行 main() の中の何も出力していない printf(
100401600: c4 c2 7d 19 77 c8 vbroadcastsd -0x38(%r15),%ymm6 100401606: c4 c1 4d 59 ba c0 24 vmulpd -0xdb40(%r10),%ymm6,%ymm7 10040160d: ff ff 10040160f: c5 d5 58 ef vaddpd %ymm7,%ymm5,%ymm5 100401613: c4 c2 7d 19 7f d0 vbroadcastsd -0x30(%r15),%ymm7 100401619: c4 41 45 59 82 00 44 vmulpd -0xbc00(%r10),%ymm7,%ymm8 100401620: ff ff 100401622: c4 c1 55 58 e8 vaddpd %ymm8,%ymm5,%ymm5 100401627: c4 42
Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?
このページを最初にブックマークしてみませんか?
『@fujitanozomuのマイページ - Qiita』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く