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 21855 - [fuzz] Assertion `Field->getInClassInitializer() && "initializer hasn't been parsed"' failed.
Summary: [fuzz] Assertion `Field->getInClassInitializer() && "initializer hasn't been ...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks: 23057
  Show dependency tree
 
Reported: 2014-12-10 15:59 PST by Sami Liedes
Modified: 2019-02-21 14:19 PST (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
test case (66 bytes, text/x-c++src)
2014-12-10 15:59 PST, Sami Liedes
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sami Liedes 2014-12-10 15:59:09 PST
Created attachment 13496 [details]
test case

Fuzzing discovered that the attached test case, when given as input to

  clang -fno-crash-diagnostics -std=c++11 -xc++ -c -emit-llvm

causes this assertion failure:

clang-3.6: tools/clang/include/clang/AST/ExprCXX.h:975: clang::Expr *clang::CXXDefaultInitExpr::getExpr(): Assertion `Field->getInClassInitializer() && "initializer hasn't been parsed"' failed.
Comment 1 Reid Kleckner 2016-10-21 17:46:20 PDT
Still repros
Comment 2 Erich Keane 2017-04-06 12:17:15 PDT
I discovered this with one of our internal tests.  Our reduced test case is similar and has the same issues:

template < class > struct A
{
    int N = sizeof (A < wchar_t >) /;
    void F()
    {
        A < wchar_t > a;
    }
};

clang -std=c++11
Comment 3 Reid Kleckner 2019-02-21 14:19:43 PST
Looks like this was fixed. Erich's example gives a proper error like so:

template <class> struct A {
  int N = sizeof(A<wchar_t>) / ;
  void F() { A<wchar_t> a; }
};

$ clang -cc1 -std=c++11 t.cpp -emit-llvm
t.cpp:3:37: error: expected expression
    int N = sizeof (A < wchar_t >) /;
                                    ^
1 error generated.

And the original attached test case doesn't crash.