Bug#794475: clang-3.6: clang segfaults on invalid use of non-static data member

2015-08-03 Thread Lorenz Hübschle-Schneider
Package: clang-3.6
Version: 1:3.6.2~+rc1-1~exp1
Severity: normal

Dear Maintainer,

I managed to make clang-3.6 segfault on a piece of code that should not compile,
as it comprises the invalid use of a non-static data member.

This also applies to clang-3.5.

The crash is 100% reproducible and also affects clang-3.5 (1:3.5.2-1) but 
appears
to be fixed in clang-3.7 (1:3.7~svn239806-1+b1). It affects clang-3.6 both from
unstable (1:3.6.1-1) and experimental (1:3.6.2~+rc1-1~exp1).

Unfortunately I have not been able to isolate what causes the crash or to
produce a minimal example, and I can't share the original code (yet -- it's
unpublished research).

crash backtrace:


OMPI_CXX=clang++-3.6 mpic++ -std=c++11 -Wall -Wextra -Werror 
-I/opt/intel/composer_xe_2015.2.164/mkl/include  -Ofast -g -flto -DNDEBUG -o 
mostfreq mostfreq.cpp /usr/lib/x86_64-linux-gnu/libgsl.a libboost_mpi.a 
libboost_serialization.a 
/opt/intel/composer_xe_2015.2.164/mkl/lib/intel64/libmkl_intel_lp64.a 
/opt/intel/composer_xe_2015.2.164/mkl/lib/intel64/libmkl_core.a 
/opt/intel/composer_xe_2015.2.164/mkl/lib/intel64/libmkl_sequential.a -ldl
In file included from mostfreq.cpp:13:
../worker_ec.h:178:48: error: invalid use of non-static data member 'k'
std::vectorelement select_dht(int rank = k) {
   ^
../worker_ec.h:178:41: error: unused parameter 'rank' 
[-Werror,-Wunused-parameter]
std::vectorelement select_dht(int rank = k) {
^
#0 0x7f991806d3a2 llvm::sys::PrintStackTrace(_IO_FILE*) 
(/usr/lib/x86_64-linux-gnu/libLLVM-3.6.so.1+0xf943a2)
#1 0x7f991806baf1 (/usr/lib/x86_64-linux-gnu/libLLVM-3.6.so.1+0xf92af1)
#2 0x7f9916cb08d0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0xf8d0)
#3 0xb62721 (/usr/lib/llvm-3.6/bin/clang+0xb62721)
#4 0xb62b35 (/usr/lib/llvm-3.6/bin/clang+0xb62b35)
#5 0xb630f2 clang::Sema::CheckCompletedExpr(clang::Expr*, 
clang::SourceLocation, bool) (/usr/lib/llvm-3.6/bin/clang+0xb630f2)
#6 0xc96118 clang::Sema::BuildCXXDefaultArgExpr(clang::SourceLocation, 
clang::FunctionDecl*, clang::ParmVarDecl*) 
(/usr/lib/llvm-3.6/bin/clang+0xc96118)
#7 0xc9646c clang::Sema::GatherArgumentsForCall(clang::SourceLocation, 
clang::FunctionDecl*, clang::FunctionProtoType const*, unsigned int, 
llvm::ArrayRefclang::Expr*, llvm::SmallVectorImplclang::Expr*, 
clang::Sema::VariadicCallType, bool, bool) 
(/usr/lib/llvm-3.6/bin/clang+0xc9646c)
#8 0xc97302 clang::Sema::ConvertArgumentsForCall(clang::CallExpr*, 
clang::Expr*, clang::FunctionDecl*, clang::FunctionProtoType const*, 
llvm::ArrayRefclang::Expr*, clang::SourceLocation, bool) 
(/usr/lib/llvm-3.6/bin/clang+0xc97302)
#9 0xd852d9 clang::Sema::BuildCallToMemberFunction(clang::Scope*, clang::Expr*, 
clang::SourceLocation, llvm::MutableArrayRefclang::Expr*, 
clang::SourceLocation) (/usr/lib/llvm-3.6/bin/clang+0xd852d9)
#10 0xc98c79 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, 
clang::SourceLocation, llvm::MutableArrayRefclang::Expr*, 
clang::SourceLocation, clang::Expr*, bool) 
(/usr/lib/llvm-3.6/bin/clang+0xc98c79)
#11 0xe36a18 (/usr/lib/llvm-3.6/bin/clang+0xe36a18)
#12 0xe32645 (/usr/lib/llvm-3.6/bin/clang+0xe32645)
#13 0xe335d1 (/usr/lib/llvm-3.6/bin/clang+0xe335d1)
#14 0xe33801 (/usr/lib/llvm-3.6/bin/clang+0xe33801)
#15 0xe3fcc5 (/usr/lib/llvm-3.6/bin/clang+0xe3fcc5)
#16 0xe40c63 (/usr/lib/llvm-3.6/bin/clang+0xe40c63)
#17 0xe40d7b (/usr/lib/llvm-3.6/bin/clang+0xe40d7b)
#18 0xe3ff35 (/usr/lib/llvm-3.6/bin/clang+0xe3ff35)
#19 0xe42ddf clang::Sema::SubstStmt(clang::Stmt*, 
clang::MultiLevelTemplateArgumentList const) 
(/usr/lib/llvm-3.6/bin/clang+0xe42ddf)
#20 0xe65280 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, 
clang::FunctionDecl*, bool, bool) (/usr/lib/llvm-3.6/bin/clang+0xe65280)
#21 0xe63efb clang::Sema::PerformPendingInstantiations(bool) 
(/usr/lib/llvm-3.6/bin/clang+0xe63efb)
#22 0xe65365 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, 
clang::FunctionDecl*, bool, bool) (/usr/lib/llvm-3.6/bin/clang+0xe65365)
#23 0xe63efb clang::Sema::PerformPendingInstantiations(bool) 
(/usr/lib/llvm-3.6/bin/clang+0xe63efb)
#24 0xb157df clang::Sema::ActOnEndOfTranslationUnit() 
(/usr/lib/llvm-3.6/bin/clang+0xb157df)
#25 0xa68fa0 
clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef) 
(/usr/lib/llvm-3.6/bin/clang+0xa68fa0)
#26 0xa5ecc3 clang::ParseAST(clang::Sema, bool, bool) 
(/usr/lib/llvm-3.6/bin/clang+0xa5ecc3)
#27 0x6efdc6 clang::FrontendAction::Execute() 
(/usr/lib/llvm-3.6/bin/clang+0x6efdc6)
#28 0x6cc2f9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction) 
(/usr/lib/llvm-3.6/bin/clang+0x6cc2f9)
#29 0x6b4c43 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
(/usr/lib/llvm-3.6/bin/clang+0x6b4c43)
#30 0x6af278 cc1_main(llvm::ArrayRefchar const*, char const*, void*) 
(/usr/lib/llvm-3.6/bin/clang+0x6af278)
#31 0x6ae8a3 main (/usr/lib/llvm-3.6/bin/clang+0x6ae8a3)
#32 0x7f9915884b45 __libc_start_main 

Bug#794475: clang-3.6: clang segfaults on invalid use of non-static data member

2015-08-03 Thread Lorenz Hübschle-Schneider
reopen 794475 =
retitle 794475 clang segfaults on failed parameter substitution in
templated class or struct

Hi,

I've managed to come up with a small test case now and it's really quite
small:

-
template typename T
struct test {
test() { foo(); }
void foo(int x = k) {}
};

int main() {
testint w;
}
-

the simplest possible invocation is enough to trigger the bug (clang++-3.6
foo.cpp)

The test case demonstrates that it's not the invalid use of a non-static
data member that causes this (there is no member k in test), but a failure
to substitute arguments. Since the crash does not occur if test isn't
templated, that probably has something to do with the issue as well.

I hope my usage of the BTS was correct.

Cheers,
Lorenz

On Mon, Aug 3, 2015 at 3:27 PM, Sylvestre Ledru sylves...@debian.org
wrote:

 Le 03/08/2015 15:11, Lorenz Hübschle-Schneider a écrit :
  Package: clang-3.6
  Version: 1:3.6.2~+rc1-1~exp1
  Severity: normal
 
 
  Unfortunately I have not been able to isolate what causes the crash or to
  produce a minimal example, and I can't share the original code (yet --
 it's
  unpublished research).
 
 Without a test case, I won't be able to do anything.

 Please reopen with a way to reproduce it... Sorry about that :(
 Maybe creduce (https://packages.debian.org/sid/creduce) could help you.

 Sylvestre