[LLVMbugs] [Bug 19488] New: Assertion fails for a braced initializer list inside function-like macro

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Apr 19 06:15:50 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19488

            Bug ID: 19488
           Summary: Assertion fails for a braced initializer list inside
                    function-like macro
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: libclang
          Assignee: unassignedclangbugs at nondot.org
          Reporter: abyss.7 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The code is _like_ this:

#include <list>
#include <string>

#define EQ(x, y) ((x) == (y))

int main() {
  EQ(std::list<std::string>{"1", "2", "3"}, std::list<std::string>());
}

If I compile it with clang++, I get an error:

> parentheses are required around macro argument containing braced initializer list

But if I try to reparse it with libclang (e.g. QtCreator 3.1.0 - see
https://bugreports.qt-project.org/browse/QTCREATORBUG-12093 ), I get the
following stack-trace:

#0  0x0000003b7fa35c39 in __GI_raise (sig=sig at entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x0000003b7fa37348 in __GI_abort () at abort.c:89
#2  0x0000003b7fa2eb96 in __assert_fail_base (fmt=0x3b7fb7bd88 "%s%s%s:%u:
%s%sAssertion `%s' failed.\n%n", assertion=assertion at entry=0x7f7c58ddfc34
"begin() + idx < end()", 
    file=file at entry=0x7f7c58ddfc4a
"/home/user/Projects/llvm/include/llvm/ADT/SmallVector.h", line=line at entry=140, 
    function=function at entry=0x7f7c58df5bee "reference
llvm::SmallVectorTemplateCommon<char, void>::operator[](unsigned int) [T =
char]") at assert.c:92
#3  0x0000003b7fa2ec42 in __GI___assert_fail (assertion=0x7f7c58ddfc34 "begin()
+ idx < end()", file=0x7f7c58ddfc4a
"/home/user/Projects/llvm/include/llvm/ADT/SmallVector.h", 
    line=140, function=0x7f7c58df5bee "reference
llvm::SmallVectorTemplateCommon<char, void>::operator[](unsigned int) [T =
char]") at assert.c:101
#4  0x00007f7c58bee0fb in clang::MacroArgs::StringifyArgument(clang::Token
const*, clang::Preprocessor&, bool, clang::SourceLocation,
clang::SourceLocation) ()
   from /home/user/.local/lib/libclang.so
#5  0x00007f7c58bee21c in clang::MacroArgs::getStringifiedArgument(unsigned
int, clang::Preprocessor&, clang::SourceLocation, clang::SourceLocation) ()
   from /home/user/.local/lib/libclang.so
#6  0x00007f7c58beb6d7 in clang::TokenLexer::ExpandFunctionArguments() () from
/home/user/.local/lib/libclang.so
#7  0x00007f7c58beacfc in clang::TokenLexer::Init(clang::Token&,
clang::SourceLocation, clang::MacroInfo*, clang::MacroArgs*) () from
/home/user/.local/lib/libclang.so
#8  0x00007f7c58bcaaea in clang::Preprocessor::EnterMacro(clang::Token&,
clang::SourceLocation, clang::MacroInfo*, clang::MacroArgs*) () from
/home/user/.local/lib/libclang.so
#9  0x00007f7c58bce226 in
clang::Preprocessor::HandleMacroExpandedIdentifier(clang::Token&,
clang::MacroDirective*) () from /home/user/.local/lib/libclang.so
#10 0x00007f7c58be8c44 in clang::Preprocessor::HandleIdentifier(clang::Token&)
() from /home/user/.local/lib/libclang.so
#11 0x00007f7c58bec069 in clang::TokenLexer::Lex(clang::Token&) () from
/home/user/.local/lib/libclang.so
#12 0x00007f7c58be8d66 in clang::Preprocessor::Lex(clang::Token&) () from
/home/user/.local/lib/libclang.so
#13 0x00007f7c5847fe50 in clang::Parser::ParseCompoundStatementBody(bool) ()
from /home/user/.local/lib/libclang.so
#14 0x00007f7c584795e4 in
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
() from /home/user/.local/lib/libclang.so
#15 0x00007f7c58478d30 in
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*) () from /home/user/.local/lib/libclang.so
#16 0x00007f7c5847be0d in
clang::Parser::ParseIfStatement(clang::SourceLocation*) () from
/home/user/.local/lib/libclang.so
#17 0x00007f7c58479a71 in
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
() from /home/user/.local/lib/libclang.so
#18 0x00007f7c58478d30 in
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*) () from /home/user/.local/lib/libclang.so
#19 0x00007f7c5847c182 in
clang::Parser::ParseIfStatement(clang::SourceLocation*) () from
/home/user/.local/lib/libclang.so
#20 0x00007f7c58479a71 in
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
() from /home/user/.local/lib/libclang.so
#21 0x00007f7c58478d30 in
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*) () from /home/user/.local/lib/libclang.so
#22 0x00007f7c58480344 in clang::Parser::ParseCompoundStatementBody(bool) ()
from /home/user/.local/lib/libclang.so
#23 0x00007f7c5845be2f in
clang::Parser::ParseLambdaExpressionAfterIntroducer(clang::LambdaIntroducer&)
() from /home/user/.local/lib/libclang.so
#24 0x00007f7c5845a17b in clang::Parser::ParseLambdaExpression() () from
/home/user/.local/lib/libclang.so
#25 0x00007f7c5844ba39 in clang::Parser::ParseCastExpression(bool, bool, bool&,
clang::Parser::TypeCastState) () from /home/user/.local/lib/libclang.so
#26 0x00007f7c584477b4 in
clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult<clang::Expr*,
true>, clang::prec::Level) () from /home/user/.local/lib/libclang.so
#27 0x00007f7c584475b6 in
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) () from
/home/user/.local/lib/libclang.so
#28 0x00007f7c58447499 in
clang::Parser::ParseExpression(clang::Parser::TypeCastState) () from
/home/user/.local/lib/libclang.so
#29 0x00007f7c5847a049 in clang::Parser::ParseExprStatement() () from
/home/user/.local/lib/libclang.so
#30 0x00007f7c584799a5 in
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
() from /home/user/.local/lib/libclang.so
#31 0x00007f7c58478d30 in
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*) () from /home/user/.local/lib/libclang.so
#32 0x00007f7c58480344 in clang::Parser::ParseCompoundStatementBody(bool) ()
from /home/user/.local/lib/libclang.so
#33 0x00007f7c584837bb in
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) () from /home/user/.local/lib/libclang.so
#34 0x00007f7c584126e5 in
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
()
   from /home/user/.local/lib/libclang.so
#35 0x00007f7c5842359d in
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool,
clang::SourceLocation*, clang::Parser::ForRangeInit*) ()
   from /home/user/.local/lib/libclang.so
#36 0x00007f7c58411c8e in
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) ()
   from /home/user/.local/lib/libclang.so
#37 0x00007f7c584116e3 in
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) ()
   from /home/user/.local/lib/libclang.so
#38 0x00007f7c584109b9 in
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) () from /home/user/.local/lib/libclang.so
#39 0x00007f7c584354d1 in
clang::Parser::ParseInnerNamespace(std::vector<clang::SourceLocation,
std::allocator<clang::SourceLocation> >&, std::vector<clang::IdentifierInfo*,
std::allocator<clang::IdentifierInfo*> >&, std::vector<clang::SourceLocation,
std::allocator<clang::SourceLocation> >&, unsigned int, clang::SourceLocation&,
clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) () from
/home/user/.local/lib/libclang.so
#40 0x00007f7c584349e4 in clang::Parser::ParseNamespace(unsigned int,
clang::SourceLocation&, clang::SourceLocation) () from
/home/user/.local/lib/libclang.so
#41 0x00007f7c5841f3bb in
clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned
int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) ()
   from /home/user/.local/lib/libclang.so
#42 0x00007f7c58410630 in
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) () from /home/user/.local/lib/libclang.so
#43 0x00007f7c584354d1 in
clang::Parser::ParseInnerNamespace(std::vector<clang::SourceLocation,
std::allocator<clang::SourceLocation> >&, std::vector<clang::IdentifierInfo*,
std::allocator<clang::IdentifierInfo*> >&, std::vector<clang::SourceLocation,
std::allocator<clang::SourceLocation> >&, unsigned int, clang::SourceLocation&,
clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) () from
/home/user/.local/lib/libclang.so
#44 0x00007f7c584349e4 in clang::Parser::ParseNamespace(unsigned int,
clang::SourceLocation&, clang::SourceLocation) () from
/home/user/.local/lib/libclang.so
#45 0x00007f7c5841f3bb in
clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned
int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) ()
   from /home/user/.local/lib/libclang.so
#46 0x00007f7c58410630 in
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) () from /home/user/.local/lib/libclang.so
#47 0x00007f7c5840ff64 in
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) ()
from /home/user/.local/lib/libclang.so
#48 0x00007f7c5840c210 in clang::ParseAST(clang::Sema&, bool, bool) () from
/home/user/.local/lib/libclang.so
#49 0x00007f7c5826fb60 in clang::FrontendAction::Execute() () from
/home/user/.local/lib/libclang.so
#50 0x00007f7c58237cca in clang::ASTUnit::Parse(llvm::MemoryBuffer*) () from
/home/user/.local/lib/libclang.so
#51 0x00007f7c5823c76a in clang::ASTUnit::Reparse(std::pair<std::string,
llvm::PointerUnion<char const*, llvm::MemoryBuffer const*> >*, unsigned int) ()
   from /home/user/.local/lib/libclang.so
#52 0x00007f7c581e039b in clang_reparseTranslationUnit_Impl(void*) () from
/home/user/.local/lib/libclang.so

---

If I put the parentheses around arguments, the libclang works fine.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140419/0a20c9de/attachment.html>


More information about the llvm-bugs mailing list