LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 18473 - clang 3.4 failed to compile C++ code that works with clang 3.3 (Segmentation fault)
Summary: clang 3.4 failed to compile C++ code that works with clang 3.3 (Segmentation ...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords: compile-fail
: 18425 18509 18719 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-01-14 05:52 PST by Feng Wang
Modified: 2014-03-30 18:03 PDT (History)
10 users (show)

See Also:
Fixed By Commit(s):


Attachments
the preprocessed c++ source file (606.66 KB, application/x-xz)
2014-01-14 05:54 PST, Feng Wang
Details
Full log of clang run (7.00 KB, application/octet-stream)
2014-01-14 11:00 PST, jonathan.sauer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Feng Wang 2014-01-14 05:52:53 PST
Upgrading to 3.4 breaks my old c++ code

Step to reproduce:

 "/usr/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -main-file-name second_order_approximation.cc -mrelocation-model static -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.24 -momit-leaf-frame-pointer -D "NDEBUG" -O3 -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-sign-conversion -Wno-exit-time-destructors -Wno-float-equal -Wno-global-constructors -Wno-missing-declarations -Wno-unused-parameter -Wno-padded -Wno-shadow -Wno-weak-vtables -Wno-missing-prototypes -std=c++11 -fdeprecated-macro -ferror-limit 2 -fmessage-length 239 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -x c++ second_order_approximation-99534a.cpp

Actual Results:
0  libLLVM-3.4.so  0x00007f3a5b6fdb22 llvm::sys::PrintStackTrace(_IO_FILE*) + 34
1  libLLVM-3.4.so  0x00007f3a5b6fd6cc
2  libpthread.so.0 0x00007f3a5a613870
3  clang           0x00000000011465a8 clang::Expr::EvaluateAsInitializer(clang::APValue&, clang::ASTContext const&, clang::VarDecl const*, llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic> >&) const + 40
4  clang           0x00000000010c5159 clang::VarDecl::evaluateValue(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic> >&) const + 121
5  clang           0x00000000010cd302 clang::VarDecl::checkInitIsICE() const + 242
6  clang           0x0000000000b504d7 clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool, bool, bool) + 1911
7  clang           0x0000000000bf01c0 clang::Sema::ActOnCapScopeReturnStmt(clang::SourceLocation, clang::Expr*) + 752
8  clang           0x0000000000bf095f clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*) + 703
9  clang           0x0000000000981940 clang::Parser::ParseReturnStatement() + 112
10 clang           0x0000000000985d5a clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) + 282
11 clang           0x0000000000986925 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, bool, clang::SourceLocation*) + 117
12 clang           0x000000000098a085 clang::Parser::ParseCompoundStatementBody(bool) + 1765
13 clang           0x000000000096ba22 clang::Parser::ParseLambdaExpressionAfterIntroducer(clang::LambdaIntroducer&) + 2962
14 clang           0x000000000096ce73 clang::Parser::ParseLambdaExpression() + 275
15 clang           0x0000000000958347 clang::Parser::ParseCastExpression(bool, bool, bool&, clang::Parser::TypeCastState) + 6455
16 clang           0x000000000095923d clang::Parser::ParseCastExpression(bool, bool, clang::Parser::TypeCastState) + 29
17 clang           0x00000000009592cf clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 31
18 clang           0x000000000096f130 clang::Parser::ParseBraceInitializer() + 368
19 clang           0x00000000009336b8 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&) + 920
20 clang           0x000000000093d3b9 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1833
21 clang           0x00000000009415cf clang::Parser::ParseSimpleDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, bool, clang::Parser::ForRangeInit*) + 815
22 clang           0x000000000094187a clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 218
23 clang           0x0000000000986100 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) + 1216
24 clang           0x0000000000986925 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, bool, clang::SourceLocation*) + 117
25 clang           0x000000000098a085 clang::Parser::ParseCompoundStatementBody(bool) + 1765
26 clang           0x000000000098c20e clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) + 190
27 clang           0x0000000000996ac4 clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) + 308
28 clang           0x00000000009968e0 clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) + 112
29 clang           0x00000000009507cc clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int, clang::Decl*) + 1548
30 clang           0x0000000000951ddc clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::Parser::ParsedAttributesWithRange&) + 2060

31 clang           0x000000000093672d clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) + 4701
32 clang           0x0000000000990527 clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 855
33 clang           0x0000000000991bf3 clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 867
34 clang           0x0000000000991ef9 clang::Parser::ParseDeclarationStartingWithTemplate(unsigned int, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 121
35 clang           0x00000000009419e8 clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 584
36 clang           0x000000000092e6c4 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) + 324
37 clang           0x000000000094b408 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&) + 376
38 clang           0x000000000094b994 clang::Parser::ParseNamespace(unsigned int, clang::SourceLocation&, clang::SourceLocation) + 1204
39 clang           0x0000000000941a40 clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 672
40 clang           0x000000000092e6c4 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) + 324
41 clang           0x000000000092ecc6 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 182
42 clang           0x000000000092536b clang::ParseAST(clang::Sema&, bool, bool) + 283
43 clang           0x00000000006610b9 clang::FrontendAction::Execute() + 169
44 clang           0x0000000000640858 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 296
45 clang           0x000000000062a7d3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1683
46 clang           0x0000000000626218 cc1_main(char const**, char const**, char const*, void*) + 1144
47 clang           0x0000000000624a4d main + 7597
48 libc.so.6       0x00007f3a59f77b05 __libc_start_main + 245
49 clang           0x00000000006252af
Stack dump:
0.      Program arguments: /usr/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -main-file-name second_order_approximation.cc -mrelocation-model static -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.24 -momit-leaf-frame-pointer -D NDEBUG -O3 -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-sign-conversion -Wno-exit-time-destructors -Wno-float-equal -Wno-global-constructors -Wno-missing-declarations -Wno-unused-parameter -Wno-padded -Wno-shadow -Wno-weak-vtables -Wno-missing-prototypes -std=c++11 -fdeprecated-macro -ferror-limit 2 -fmessage-length 239 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -x c++ second_order_approximation-99534a.cpp
1.      include/f/variate_generator/vg/distribution/burr.hpp:91:66: current parser token ';'
2.      include/f/variate_generator/vg/distribution/burr.hpp:28:1: parsing namespace 'f'
3.      include/f/variate_generator/vg/distribution/burr.hpp:32:5: parsing struct/union/class body 'burr'
4.      include/f/variate_generator/vg/distribution/burr.hpp:77:13: parsing function body 'direct_burr_impl'
5.      include/f/variate_generator/vg/distribution/burr.hpp:77:13: in compound statement ('{}')
6.      include/f/variate_generator/vg/distribution/burr.hpp:90:21: lambda expression parsing
7.      include/f/variate_generator/vg/distribution/burr.hpp:91:21: in compound statement ('{}')
./second_order_approximation-99534a.sh: line 1: 12116 Segmentation fault      (core dumped) "/usr/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -main-file-name second_order_approximation.cc -mrelocation-model static -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.24 -momit-leaf-frame-pointer -D "NDEBUG" -O3 -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-sign-conversion -Wno-exit-time-destructors -Wno-float-equal -Wno-global-constructors -Wno-missing-declarations -Wno-unused-parameter -Wno-padded -Wno-shadow -Wno-weak-vtables -Wno-missing-prototypes -std=c++11 -fdeprecated-macro -ferror-limit 2 -fmessage-length 239 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -x c++ second_order_approximation-99534a.cpp

Expected Results:
clang3.4 compiles my code as clang3.3 does

Build Date & Platform:
Linux 3.10.24-1-lts #1 SMP Tue Jan 14 12:53:09 CET 2014 x86_64 GNU/Linux
Comment 1 Feng Wang 2014-01-14 05:54:55 PST
Created attachment 11869 [details]
the preprocessed c++ source file
Comment 2 jonathan.sauer 2014-01-14 11:00:08 PST
Created attachment 11870 [details]
Full log of clang run

Reduced:

template < typename final_type >
void direct_burr_impl()
{
	static const final_type l(1);
	
	[](const final_type u) -> final_type { return -l + u; };
}


Compiling this with clang r199081 (3.5, trunk) results in (full log attached):
Comment 3 jonathan.sauer 2014-01-14 11:02:25 PST
Changing the line

  static const final_type l(1)

to

  static const float l(1)

that is a non-dependent type, makes the code compile.
Comment 4 Feng Wang 2014-01-16 07:52:37 PST
I tested the following code:

template < typename final_type >
void direct_burr_impl()
{
    static const final_type l(1);

    [](const final_type u) -> final_type { return -l + u; };
}

int main()
{
    direct_burr_impl<int>();
    direct_burr_impl<float>();
    direct_burr_impl<double>();
    direct_burr_impl<long double>();

    return 0;
}

successful with VS2012, clang3.2, clang3.3, g++4.5.3, g++4.6.4, g++4.7.3, g++4.8.1, g++4.9.0, Icc13.0.1, *ONLY* clang3.4 crashes.
Comment 5 Richard Smith 2014-01-16 15:17:57 PST
*** Bug 18509 has been marked as a duplicate of this bug. ***
Comment 6 Faisal Vali 2014-01-18 17:05:40 PST
A patch that should fix this bug has been submitted for review:
http://llvm-reviews.chandlerc.com/D2575
Comment 7 Richard Smith 2014-02-06 16:55:58 PST
*** Bug 18425 has been marked as a duplicate of this bug. ***
Comment 8 Richard Smith 2014-02-06 16:56:09 PST
*** Bug 18719 has been marked as a duplicate of this bug. ***
Comment 9 Richard Smith 2014-02-06 17:35:57 PST
Fixed in r200954.
Comment 10 Cody Maloney 2014-02-10 21:46:59 PST
Could this fix be backported to the 3.4 branch so it gets into the 3.4.1 release?
Comment 11 Richard Smith 2014-02-18 12:52:49 PST
Seems like a good candidate for 3.4.1.