This is an archive of the discontinued LLVM Phabricator instance.

Leftover expressions for ODR use checking after fatal error (if you ignore them)
Needs ReviewPublic

Authored by azat on Mar 19 2015, 12:19 PM.

Details

Summary

Using simple source code:

$ cat /tmp/string.cpp                                                                                                                                                                                                                                                             
#include <string>
int main()
{
        std::string a("a");
        a = std::to_string((float)1);
        return a.length();
}

With clang::ASTFrontendAction::ExecuteAction() the next assertion bails:

/src/oss/clang/lib/Sema/SemaDecl.cpp:10637: clang::Decl* clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool): Assertion `MaybeODRUseExprs.empty() && "Leftover expressions for odr-use checking"' failed.

But if I compile the same source using clang++ everything is fine, because size_t is defined there, while if I use ASTFrontendAction size_t is not defined, and if you will ignore errors, than it will bail in ActOnFinishFunctionBody().

Anyway, I've digged this, and got simple regression test for this.
I guess that this could be not the correct fix, but this how I fixed this in a few days.

http://lists.cs.uiuc.edu/pipermail/cfe-dev/2015-February/041726.html

Diff Detail

Event Timeline

azat updated this revision to Diff 22293.Mar 19 2015, 12:19 PM
azat retitled this revision from to Leftover expressions for ODR use checking after fatal error (if you ignore them).
azat updated this object.
azat edited the test plan for this revision. (Show Details)
azat updated this object.Mar 19 2015, 12:29 PM
azat added a subscriber: Unknown Object (MLST).