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 21860 - [fuzz] Assertion `hasInClassInitializer() && InitStorage.getPointer() == nullptr && "bit width, initializer or captured type already set"' failed.
Summary: [fuzz] Assertion `hasInClassInitializer() && InitStorage.getPointer() == null...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++11 (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 16:06 PST by Sami Liedes
Modified: 2016-10-21 18:30 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments
test case (81 bytes, text/x-c++src)
2014-12-10 16:06 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 16:06:46 PST
Created attachment 13501 [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/Decl.h:2299: void clang::FieldDecl::setInClassInitializer(clang::Expr *): Assertion `hasInClassInitializer() && InitStorage.getPointer() == nullptr && "bit width, initializer or captured type already set"' failed.
Comment 1 David Majnemer 2014-12-13 03:43:39 PST
cleaned up a bit:
template <typename> struct e {
  operator int();
  int np1 = e();
};
e<int> a = e<int>();

GCC and MSVC both accept (but generate code that may infinitely recurse).
Comment 2 David Majnemer 2014-12-13 03:48:40 PST
Richard, it looks like we keep instantiating the same template over and over again. Any ideas?
Comment 3 Reid Kleckner 2016-10-21 18:30:35 PDT
We now reject:

C:/Users/rnk/Downloads/funs-without-prototype.cpp:1:28: error: default member initializer for 'np1' uses itself
template <typename> struct e {
                           ^
C:/Users/rnk/Downloads/funs-without-prototype.cpp:1:28: note: in instantiation of default member initializer 'e<int>::np1' requested here
C:/Users/rnk/Downloads/funs-without-prototype.cpp:1:28: note: in instantiation of default member initializer 'e<int>::np1' requested here
C:/Users/rnk/Downloads/funs-without-prototype.cpp:3:13: note: implicit default constructor for 'e<int>' first required here
  int np1 = e();
            ^
C:/Users/rnk/Downloads/funs-without-prototype.cpp:5:12: note: implicit default constructor for 'e<int>' first required here
e<int> a = e<int>();
           ^