可能的编译器故障而在MSVC12(VS2013)用指定的初始化 [英] Possible compiler bug in MSVC12 (VS2013) with designated initializer
问题描述
使用VS2013更新2中,我无意中发现了一些奇怪的错误消息:
Using VS2013 Update 2, I've stumbled on some strange error message :
// test.c
int main(void)
{
struct foo {
int i;
float f;
};
struct bar {
unsigned u;
struct foo foo;
double d;
};
struct foo some_foo = {
.i = 1,
.f = 2.0
};
struct bar some_bar = {
.u = 3,
// error C2440 : 'initializing' : cannot convert from 'foo' to 'int'
.foo = some_foo,
.d = 4.0
};
// Works fine
some_bar.foo = some_foo;
return 0;
}
GCC和锵接受它。
Both GCC and Clang accept it.
我缺少的东西,还是在这片code的公开编译器错误?
Am I missing something or does this piece of code exposes a compiler bug ?
编辑:复制:<一href=\"https://stackoverflow.com/questions/23707402/initializing-struct-within-another-struct-using-designated-initializer-causes-co\">Initializing使用指定的初始化导致另一个结构内结构编译错误在Visual Studio 2013
推荐答案
这是一个<一个href=\"http://www.beta.microsoft.com/VisualStudio/feedback/details/805981/msvc-2013-c99-designated-initializers-cannot-initialize-unions-within-structs\"相对=nofollow>已知的bug 。据说这是固定在MSVC的下一个版本。
It is a known bug. It is said to be fixed in the next version of MSVC.
编辑:不幸的是,错误仍在present在VS14 CTP 4
Unfortunately, the bug is still present in VS14 CTP 4.
编辑:此bug已被固定在VS2015 CTP 5
This bug has been fixed in VS2015 CTP 5.
这篇关于可能的编译器故障而在MSVC12(VS2013)用指定的初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!