我试图推行“标签的价值”的价值观(https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html)使用铛3.7在Visual Studio 2015年标签是铛
作为一个玩具示例性交流计划,我有以下代码会导致编译编译器文件'c:\ agent \ build \ cache \ git \ vctools \ vctools \ compiler \ utc \ src \ p2 \ main编译器文件'c:\ agent \ build \ cache \ git \ .c',第246行) 1>要解决此问题,请尝试简化或更改上述位置附近的程序。“)。
const void *array_jump[] = {&&S1,&&S2,&&S3,&&S3,&&S4};
S1:
goto *array_jump[3];
S2:
return 2;
S3:
return 3;
S4:
return 4;
如果我移动阵列声明毕竟它的工作标签,直到我包括任何语句的array_jump变量。
S1:
//comment out and add "return 1;" and it will compile fine
goto *array_jump[3];
S2:
return 2;
S3:
return 3;
S4:
return 4;
const void *array_jump[] = {&&S1,&&S2,&&S3,&&S3,&&S4};
任何人都可以提供一个像上面那个应该工作的例子吗?这是铿锵声或Visual Studio的“codegen”方面的问题吗?
我觉得这个bug是相关的,但我不知道: https://connect.microsoft.com/VisualStudio/feedback/details/2103400/crash-in-clang-c2-with-address-of-label-extension
这是可怕的编码风格。你为什么不使用'switch'或函数表。如果你真的想要这样的代码,你应该'goto' 70ies/80ies BASIC。 – Olaf