https://llvm.org/bugs/show_bug.cgi?id=23514
Bug ID: 23514
Summary: Out-of-sequence initialiser causes clang to crash
Product: clang
Version: 3.6
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
A simplified test case:
struct S {
S(int a) : a(a) { }
int a;
};
struct P {
char i1 : 1;
char i2 : 7;
S s; // avoid crash by changing "S" to "int"
};
static P MakeP() {
return P { .i1 = 1, .s = 2, .i2 = 3 }; // or using correct order
}
The code as it stands above crashes clang with...
SemaInit.cpp:6455: void diagnoseListInit(clang::Sema&, const
clang::InitializedEntity&, clang::InitListExpr*): Assertion
`DiagnoseInitList.HadError() && "Inconsistent init list check result."' failed.
This is the outcome on clang 3.6.0 and 3.4.1 (which are the two versions I have
tested).
There are two work-arounds that avoid the crash:
1. Change P::s to "int" rather than "struct S"
2. Use a sequential initialisation order in MakeP()
It seems that clang cannot handle this particular scenario where others are ok.
The following arrangement for "struct P" is, however, ok (oddly?):
struct P {
S s;
char i2 : 7;
char i1 : 1;
};
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs