[cfe-dev] Clang 3.2 assertion failure issuing diagnostics when compiling from AST files.

Tom Honermann thonermann at coverity.com
Wed Feb 27 12:35:04 PST 2013

This issue reproduces with Clang 3.2 and with Clang trunk as of yesterday.

The following bug has been filed for this:
   Bug 15377 - Clang assertion failure when issuing a diagnostic while 
compiling from an AST file

This code is ill-formed:

$ cat t.cpp
template<typename T>
T tf() {
     static const T i;
     return i;

void f() {

Compiling it directly to object file results in an appropriate diagnostic:

$ clang -c t.cpp
t.cpp:5:20: error: default initialization of an object of const type 
'const int'
     static const T i;
t.cpp:10:5: note: in instantiation of function template specialization 
       requested here
1 error generated.

Emitting to an AST file and then compiling from it results in an 
assertion failure when constructing the diagnostic:

$ clang -emit-ast t.cpp
$ clang -c t.ast
clang: lib/Frontend/TextDiagnosticPrinter.cpp:148: virtual void 
const clang::Diagnostic&): Assertion `TextDiag && "Unexpected diagnostic 
outside source file processing"' failed.
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see 
clang version 3.2 (tags/RELEASE_32/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to 
http://llvm.org/bugs/ and include the crash backtrace, preprocessed 
source, and associated run script.
clang: note: diagnostic msg: Error generating preprocessed source(s) - 
no preprocessable inputs.

Backtrace and further information are available in the bug report.


More information about the cfe-dev mailing list