- Visual Studio 2013 SP3
175 :デフォルトの名無しさん[sage]:2014/03/31(月) 15:59:12.63 ID:AKfTTJsa - ↓これはエラー
#include <windows.h> int hoge(int hoge) { if (hoge == 0) goto hoge; HGLOBAL h = 0; return hoge * 2 + (h == NULL); hoge: return 0; } hoge.c(7) : error C2275: 'HANDLE' : illegal use of this type as an expression C:\Program Files (x86)\Windows Kits\8.1\include\um\winnt.h(571) : see declaration of 'HANDLE' hoge.c(7) : error C2146: syntax error : missing ';' before identifier 'h' hoge.c(7) : error C2065: 'h' : undeclared identifier hoge.c(8) : error C2065: 'h' : undeclared identifier hoge.c(8) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *' ↓これは通る。 なんで? #include <windows.h> int hoge(int hoge) { if (hoge == 0) { goto hoge; } HANDLE h = 0; return hoge * 2 + (h == NULL); hoge: return 0; } > cl -c hoge.c Microsoft (R) C/C++ Optimizing Compiler Version 18.00.21005.1 for x64 Copyright (C) Microsoft Corporation. All rights reserved.
|
- Visual Studio 2013 SP3
176 :デフォルトの名無しさん[sage]:2014/03/31(月) 16:04:11.05 ID:AKfTTJsa - #include <windows.h>
int hoge(int hoge) { if (hoge == 0) goto hoge; { } HANDLE h = 0; return hoge * 2 + (h == NULL); hoge: return 0; } #include <windows.h> int hoge(int hoge) { if (hoge == 0) goto hoge; int h = 0; return hoge * 2 + (h == 0); hoge: return 0; } 両方ともとおる。コンパイラのバグか?
|
- Visual Studio 2013 SP3
182 :デフォルトの名無しさん[sage]:2014/03/31(月) 21:13:04.68 ID:AKfTTJsa - ラベル名は別の名前空間だから規格に合ってて問題ない。
引数が外部名(関数名)を隠蔽するのも規格に合ってて問題ない。 if (0) goto hoge;; i h; hoge: とgoto hoge;のあとに空文でも存在すれば通るね。MS CONNECTに投げてみた。
|