[Issue 11553] dmd segfault with recursive template

2014-01-07 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=11553


Kenji Hara k.hara...@gmail.com changed:

   What|Removed |Added

   Severity|major   |regression


--- Comment #7 from Kenji Hara k.hara...@gmail.com 2014-01-07 02:31:10 PST ---
(In reply to comment #0)
 An example that is clearly wrong code, but segfaults the compiler on
 Scope::push
 
 template A(alias T)
 {
 template A()
 {
 alias A = T!();
 }
 }
 alias B() = A!(.B);
 
 static if(A!B){}

With 2.063, following equivalent code did not cause segfault.

template A(alias T)
{
template A()
{
alias A = T!();
}
}
template B() { alias B = A!(.B); }
static if (A!B) {}  // Line 9

Output:
test.d(9): Error: expression template A() of type void does not have a boolean
value

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 11553] dmd segfault with recursive template

2014-01-07 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=11553



--- Comment #8 from github-bugzi...@puremagic.com 2014-01-07 02:33:10 PST ---
Commit pushed to 2.065 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/e1866902b88e36537197da16b098afd2df304425
Merge pull request #2826 from 9rnsr/fix11553

Issue 11553 - dmd segfault with recursive template

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 11553] dmd segfault with recursive template

2014-01-05 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=11553


Kenji Hara k.hara...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 11553] dmd segfault with recursive template

2013-11-19 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=11553



--- Comment #1 from John Colvin john.loughran.col...@gmail.com 2013-11-19 
13:45:55 GMT ---
Ok this is proving near impossible to reduce. Changing the slightest things
moves the segfault to different parts of the compiler and it's very hard to
find examples that are correct and fail. I've seen 

Scope::Scope(Scope*),

functionResolve(Match*, Dsymbol*, Loc, Scope*, ArrayRootObject*, Type*,
ArrayExpression*)::ParamDeduce::fp(TemplateDeclaration*),

TemplateInstance::findBestMatch(Scope*, ArrayExpression*) (), 

TemplateTupleParameter::matchArg(Loc, Scope*, ArrayRootObject*, unsigned
long, ArrayTemplateParameter*, ArrayRootObject*, Declaration**) (),

Dsymbol::Dsymbol()

so far, if that's of any help at all.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 11553] dmd segfault with recursive template

2013-11-19 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=11553


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 CC||yebbl...@gmail.com


--- Comment #2 from yebblies yebbl...@gmail.com 2013-11-20 01:07:34 EST ---
(In reply to comment #1)
 Ok this is proving near impossible to reduce. Changing the slightest things
 moves the segfault to different parts of the compiler and it's very hard to
 find examples that are correct and fail. I've seen 
 
 Scope::Scope(Scope*),
 
 functionResolve(Match*, Dsymbol*, Loc, Scope*, ArrayRootObject*, Type*,
 ArrayExpression*)::ParamDeduce::fp(TemplateDeclaration*),
 
 TemplateInstance::findBestMatch(Scope*, ArrayExpression*) (), 
 
 TemplateTupleParameter::matchArg(Loc, Scope*, ArrayRootObject*, unsigned
 long, ArrayTemplateParameter*, ArrayRootObject*, Declaration**) (),
 
 Dsymbol::Dsymbol()
 
 so far, if that's of any help at all.

It's jumping around because the segfault is a stack overflow.  Chances are any
segfault you see will be the same thing underneath.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 11553] dmd segfault with recursive template

2013-11-19 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=11553



--- Comment #3 from John Colvin john.loughran.col...@gmail.com 2013-11-19 
14:42:42 GMT ---
Finally, a correct (should compile) example that causes a segfault. It's still
a little large, sorry:

struct Pack(T ...)
{
alias Unpack = T;
enum length = T.length;
}

template isPack(TList ...)
{
static if(TList.length == 1 
  is(Pack!(TList[0].Unpack) == TList[0]))
{
enum isPack = true;
}
else
{
enum isPack = false;
}
}

template PartialApply(alias T, uint argLoc, Arg ...)
if(Arg.length == 1)
{
template PartialApply(L ...)
{
alias PartialApply = T!(L[0 .. argLoc], Arg, L[argLoc .. $]);
}
}

template _hasLength(size_t len, T)
{
static if(T.length == len)
{
enum _hasLength = true;
}
else
{   
enum _hasLength = false;
}
}

alias _hasLength(size_t len) = PartialApply!(._hasLength, 0, len);


alias hl1 = _hasLength!1;

//this segfaults
static if(!isPack!hl1){ pragma(msg, All good 1); }

//these are fine
static if(hl1!(Pack!(5))) { pragma(msg, All good 2); }

static if(!hl1!(Pack!())) { pragma(msg, All good 3); }


The result:
Program received signal SIGSEGV, Segmentation fault.
0x00434a45 in Dsymbol::Dsymbol(Identifier*) ()

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 11553] dmd segfault with recursive template

2013-11-19 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=11553


Kenji Hara k.hara...@gmail.com changed:

   What|Removed |Added

   Keywords||ice, pull


--- Comment #4 from Kenji Hara k.hara...@gmail.com 2013-11-19 07:48:46 PST ---
https://github.com/D-Programming-Language/dmd/pull/2826

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---