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

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Mar 18 15:57:29 PDT 2013


Fixed in r177336, thanks for reporting the issue!

-Argyrios

On Feb 27, 2013, at 8:00 PM, Tom Honermann <thonermann at coverity.com> wrote:

> Here is another example test case.  The diagnostic in this case is a warning, not an error.
> 
> $ cat t.cpp
> template<typename T>
> struct S {
>    T *mf();
> };
> template<typename T>
> T *S<T>::mf() {
>    // warning: control reaches end of non-void function [-Wreturn-type]
> }
> 
> void f() {
>    S<int>().mf();
> }
> 
> 
> I suspect the assertion failure occurs whenever a diagnostic is issued for a template instantiation in an AST file, but I haven't tried to prove this.
> 
> I added this example to the bug report as well.
> 
> Tom.
> 
> On 02/27/2013 03:35 PM, Tom Honermann wrote:
>> 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
>>   http://llvm.org/bugs/show_bug.cgi?id=15377
>> 
>> This code is ill-formed:
>> 
>> $ cat t.cpp
>> template<typename T>
>> T tf() {
>>     static const T i;
>>     return i;
>> }
>> 
>> void f() {
>>     tf<int>();
>> }
>> 
>> 
>> 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
>> 'tf<int>'
>>       requested here
>>     tf<int>();
>>     ^
>> 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
>> clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level,
>> 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
>> invocation)
>> 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.
>> 
>> Tom.
>> 
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>> 
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130318/5589f40b/attachment.html>


More information about the cfe-dev mailing list