[LLVMbugs] [Bug 11148] New: Clang crashes with g++ 4.6 header files

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Oct 16 22:29:16 PDT 2011


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

           Summary: Clang crashes with g++ 4.6 header files
           Product: clang
           Version: 2.9
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: thanhdk at gmail.com
                CC: llvmbugs at cs.uiuc.edu


When I try to compile a very simple c++ file (just declare a new stl vector)
and compile with clang 2.9:
clang -I. -I/usr/include/c++/4.6 -I/usr/include/c++/4.6/x86_64-linux-gnu/.
-I/usr/include/c++/4.6/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.6.1/include
-I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.6.1/include-fixed
-I/usr/include/x86_64-linux-gnu -std=c++0x hello.cc

Here is the source file:
#include <vector>
using namespace std;

int main()
{
    vector<int> v;
    return 0;
}

Here's the output from clang:

In file included from /usr/include/c++/4.6/vector:60:
In file included from /usr/include/c++/4.6/bits/stl_algobase.h:65:
In file included from /usr/include/c++/4.6/bits/stl_pair.h:60:
In file included from /usr/include/c++/4.6/bits/move.h:53:
/usr/include/c++/4.6/type_traits:630:59: error: '_Tp' does not refer to a value
    : public integral_constant<bool, __is_standard_layout(_Tp)>
                                                          ^
/usr/include/c++/4.6/type_traits:628:21: note: declared here
  template<typename _Tp>
                    ^
/usr/include/c++/4.6/type_traits:631:8: error: expected class name
    { };
       ^
/usr/include/c++/4.6/type_traits:631:8: error: expected '{' after base class
list
/usr/include/c++/4.6/type_traits:643:56: error: '_Tp' does not refer to a value
    : public integral_constant<bool, __is_literal_type(_Tp)>
                                                       ^
/usr/include/c++/4.6/type_traits:641:21: note: declared here
  template<typename _Tp>
                    ^
/usr/include/c++/4.6/type_traits:644:8: error: expected class name
    { };
       ^
/usr/include/c++/4.6/type_traits:644:8: error: expected '{' after base class
list
/usr/include/c++/4.6/type_traits:647:56: error: expected function body after
function declarator
    typename add_rvalue_reference<_Tp>::type declval() noexcept;
                                                       ^
/usr/include/c++/4.6/type_traits:654:30: error: use of undeclared identifier
'declval'
        static decltype(_Tp1(declval<_Args1>()...), __one()) __test(int);
                             ^
/usr/include/c++/4.6/type_traits:654:38: error: '_Args1' does not refer to a
value
        static decltype(_Tp1(declval<_Args1>()...), __one()) __test(int);
                                     ^
/usr/include/c++/4.6/type_traits:653:43: note: declared here
      template<typename _Tp1, typename... _Args1>
                                          ^
/usr/include/c++/4.6/type_traits:654:46: error: expected expression
        static decltype(_Tp1(declval<_Args1>()...), __one()) __test(int);
                                             ^
/usr/include/c++/4.6/type_traits:654:62: error: C++ requires a type specifier
for all declarations
        static decltype(_Tp1(declval<_Args1>()...), __one()) __test(int);
        ~~~~~~                                               ^
/usr/include/c++/4.6/type_traits:668:43: error: use of undeclared identifier
'declval'
        static decltype(static_cast<_Tp1>(declval<_Arg1>()), __one())
                                          ^
/usr/include/c++/4.6/type_traits:668:51: error: '_Arg1' does not refer to a
value
        static decltype(static_cast<_Tp1>(declval<_Arg1>()), __one())
                                                  ^
/usr/include/c++/4.6/type_traits:667:40: note: declared here
      template<typename _Tp1, typename _Arg1>
                                       ^
/usr/include/c++/4.6/type_traits:668:58: error: expected expression
        static decltype(static_cast<_Tp1>(declval<_Arg1>()), __one())
                                                         ^
/usr/include/c++/4.6/type_traits:669:2: error: C++ requires a type specifier
for all declarations
        __test(int);
        ^
/usr/include/c++/4.6/type_traits:694:48: error: use of undeclared identifier
'declval'
    { static const bool __value = noexcept(_Tp(declval<_Args>()...)); };
                                               ^
/usr/include/c++/4.6/type_traits:694:56: error: '_Args' does not refer to a
value
    { static const bool __value = noexcept(_Tp(declval<_Args>()...)); };
                                                       ^
/usr/include/c++/4.6/type_traits:692:38: note: declared here
  template<typename _Tp, typename... _Args>
                                     ^
/usr/include/c++/4.6/type_traits:694:63: error: expected expression
    { static const bool __value = noexcept(_Tp(declval<_Args>()...)); };
                                                              ^
/usr/include/c++/4.6/type_traits:699:61: error: use of undeclared identifier
'declval'
      static const bool __value = noexcept(static_cast<_Tp>(declval<_Arg>()));
                                                            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
0  libLLVM-2.9.so.1 0x00007ffd02f57caf
1  libLLVM-2.9.so.1 0x00007ffd02f58271
2  libpthread.so.0  0x00007ffd02119060
3  clang            0x00000000007f27a7
clang::Sema::CheckConstructor(clang::CXXConstructorDecl*) + 183
4  clang            0x00000000007d7533
5  clang            0x000000000093b718
clang::TemplateDeclInstantiator::VisitCXXMethodDecl(clang::CXXMethodDecl*,
clang::TemplateParameterList*) + 2552
6  clang            0x0000000000924875
clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*,
clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&,
clang::TemplateSpecializationKind, bool) + 1429
7  clang            0x0000000000925333
clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation,
clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind,
bool) + 1235
8  clang            0x000000000094b1b9
clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType,
clang::PartialDiagnostic const&, std::pair<clang::SourceLocation,
clang::PartialDiagnostic>) + 1001
9  clang            0x000000000094b217
clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType,
unsigned int) + 87
10 clang            0x000000000078af44
clang::Sema::CheckParmsForFunctionDef(clang::ParmVarDecl**,
clang::ParmVarDecl**, bool) + 228
11 clang            0x00000000007d1e5f
clang::Sema::ActOnStartOfFunctionDef(clang::Scope*, clang::Decl*) + 463
12 clang            0x000000000075c640
clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) + 336
13 clang            0x000000000075c479
clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) + 121
14 clang            0x000000000073ed9c
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, unsigned int,
clang::Decl*) + 1020
15 clang            0x000000000073fe70
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool) + 3072
16 clang            0x00000000007301c3
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext) + 2147
17 clang            0x00000000007570cf
clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int,
clang::Parser::ParsedTemplateInfo const&,
clang::Parser::ParsingDeclRAIIObject&, clang::SourceLocation&,
clang::AccessSpecifier) + 639
18 clang            0x000000000075a106
clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier) + 614
19 clang            0x000000000073181a
clang::Parser::ParseDeclaration(clang::ASTOwningVector<clang::Stmt*, 32u>&,
unsigned int, clang::SourceLocation&,
clang::Parser::ParsedAttributesWithRange&) + 506
20 clang            0x000000000072853e
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::Parser::ParsingDeclSpec*) + 1582
21 clang            0x000000000073bbb3 clang::Parser::ParseNamespace(unsigned
int, clang::SourceLocation&, clang::SourceLocation) + 1603
22 clang            0x00000000007317a3
clang::Parser::ParseDeclaration(clang::ASTOwningVector<clang::Stmt*, 32u>&,
unsigned int, clang::SourceLocation&,
clang::Parser::ParsedAttributesWithRange&) + 387
23 clang            0x000000000072853e
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::Parser::ParsingDeclSpec*) + 1582
24 clang            0x0000000000728c8d
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 109
25 clang            0x000000000070b750 clang::ParseAST(clang::Sema&, bool) +
128
26 clang            0x00000000006016c3 clang::CodeGenAction::ExecuteAction() +
51
27 clang            0x0000000000534aeb
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 283
28 clang            0x000000000051aa3b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 971
29 clang            0x0000000000512ef7 cc1_main(char const**, char const**,
char const*, void*) + 727
30 clang            0x0000000000511a7a main + 634
31 libc.so.6        0x00007ffd0186e30d __libc_start_main + 237
32 clang            0x0000000000512ac5
Stack dump:
0.    Program arguments: /usr/bin/clang -cc1 -triple x86_64-pc-linux-gnu
-emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name
hello.cc -mrelocation-model static -mdisable-fp-elim -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.21.53.20110810 -momit-leaf-frame-pointer -resource-dir
/usr/bin/../lib/clang/2.9 -I . -I /usr/include/c++/4.6 -I
/usr/include/c++/4.6/x86_64-linux-gnu/. -I /usr/include/c++/4.6/backward -I
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/include -I /usr/local/include -I
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/include-fixed -I
/usr/include/x86_64-linux-gnu -std=c++0x -ferror-limit 19 -fmessage-length 118
-fcxx-exceptions -fexceptions -fgnu-runtime -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/cc-xcBtq2.o -x c++ hello.cc 
1.    /usr/include/c++/4.6/bits/stl_bvector.h:540:5: current parser token ':'
2.    /usr/include/c++/4.6/bits/stl_bvector.h:457:1: parsing namespace 'std'
3.    /usr/include/c++/4.6/bits/stl_bvector.h:479:3: parsing struct/union/class
body 'vector'
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal 1 (use -v to see
invocation)

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list