[LLVMbugs] [Bug 23514] New: Out-of-sequence initialiser causes clang to crash

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed May 13 06:29:30 PDT 2015


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: unassignedclangbugs at nondot.org
          Reporter: andyg1001 at hotmail.co.uk
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150513/3f068141/attachment.html>


More information about the llvm-bugs mailing list