LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 12061 - Assertion failed: ((!Initializer || isa<ImplicitValueInitExpr>(Initializer) || isa<CXXConstructExpr>(Initializer)) && "Initializer expression that cannot have been implicitly created.")
Summary: Assertion failed: ((!Initializer || isa<ImplicitValueInitExpr>(Initializer) |...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: trunk
Hardware: PC All
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
: 12065 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-02-21 15:53 PST by Ted Kremenek
Modified: 2012-02-23 09:01 PST (History)
7 users (show)

See Also:
Fixed By Commit(s):


Attachments
delta-reduced example (1.31 KB, application/octet-stream)
2012-02-21 15:53 PST, Ted Kremenek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ted Kremenek 2012-02-21 15:53:09 PST
Created attachment 8088 [details]
delta-reduced example

Attached is a delta-reduced example that crashes clang with an assertion failure:

Assertion failed: ((!Initializer || isa<ImplicitValueInitExpr>(Initializer) || isa<CXXConstructExpr>(Initializer)) && "Initializer expression that cannot have been implicitly created."), function BuildCXXNew, file /Users/kremenek/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp, line 1023.

While this is invalid code, this assertion failure occurred on the original example which was well-formed.

I believe this is a potential regression related to the generalized initializers work.

To reproduce:

% clang -fsyntax-only reduced.ii
Comment 1 Ted Kremenek 2012-02-21 15:54:19 PST
Related: <rdar://problem/10832617>
Comment 2 Matt Beaumont-Gay 2012-02-21 15:58:38 PST
Here's a smaller test case, also reduced from well-formed code:

template <class C> struct scoped_array {
  scoped_array(C* p = __null);
};
template <class Payload> struct Foo {
  Foo() : a_(new scoped_array<int>[5]) { }
  scoped_array< scoped_array<int> > a_;
};
class Bar {};
Foo<Bar> x;
Comment 3 Nico Weber 2012-02-21 18:36:01 PST
This breaks chrome too. Here's the reduced test case for that:

class MessageLoop {
public:
  explicit MessageLoop(int type = 0);
};

template <class CookieStoreTestTraits>
class CookieStoreTest {
protected:
  CookieStoreTest() {
    new MessageLoop;
  }
};

struct CookieMonsterTestTraits {
};

class DeferredCookieTaskTest : public CookieStoreTest<CookieMonsterTestTraits> {
  DeferredCookieTaskTest() {}
};
Comment 4 Sebastian Redl 2012-02-22 03:08:41 PST
Fixed in r151146. Now compiles Matt's and Nico's test cases cleanly, and doesn't crash on Ted's (there's no way to compile that one cleanly). Also works with a variant of Matt's case with two default arguments.
Comment 5 Sebastian Redl 2012-02-22 09:37:08 PST
*** Bug 12065 has been marked as a duplicate of this bug. ***
Comment 6 Sebastian Redl 2012-02-23 09:01:17 PST
*** Bug 12065 has been marked as a duplicate of this bug. ***