2014/06/30

夏だし、怖い話しようぜ!
#include <cstdio>
#include <math.h>
 
class C {
public:
  C() {}
  C(double) { printf("hello world\n"); }
};
 
int main(int argc, char** argv)
{
  C(NAN);
  return 0;
}
僕は今日... こんなコードをコンパイルしたんだ...。gcc でコンパイルして実行したんだ...。

hello world 期待通りだった。
僕は安心し、これを今度は MSVC でビルドしたんだ...。

実行すると...

何も出ない...

僕は怖くなった。

何なんだ!何なんだ!NaN なんだーーー!

僕の C++ 人生はなんだったのか...。僕は病に侵されているに違いない...。

怖いながらもデバッガで追ったんだ...

C++ の怖い話
そしてステップインした...
C++ の怖い話
C++ の怖い話
えっ...

尋常ではない程の汗が僕の頬を伝った。

まっ...まさか!

そう、MSVC には NAN が宣言されていない。
これのおかげで2時間程無駄にした。
Fix test. MSVC doesn't have definition of NAN by mattn - Pull Request #43 - kazuho/picojson - GitHub

Note: https://gist.github.com/mattn/bf1e56aa832c031e5df6 illustrates the problem. MSVC somehow succe...

https://github.com/kazuho/picojson/pull/43
NAN が宣言されていない為に、NAN という変数が宣言されてしまっていた。
NAN なんだ、まったく。
酷い一日だった。
なんて日だ!
Posted at 20:36 | WriteBacks () | Edit
Edit this entry...

wikieditish message: Ready to edit this entry.






















A quick preview will be rendered here when you click "Preview" button.