D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 14240 - Segfault while compiling templated code
Summary: Segfault while compiling templated code
Status: RESOLVED DUPLICATE of issue 14642
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-03 18:22 UTC by lord_sigma
Modified: 2015-06-04 06:08 UTC (History)
0 users

See Also:


Attachments
GDB's backtrace (1.54 KB, text/plain)
2015-03-03 18:22 UTC, lord_sigma
Details

Note You need to log in before you can comment on or make changes to this issue.
Description lord_sigma 2015-03-03 18:22:12 UTC
Created attachment 1479 [details]
GDB's backtrace

Dustmited source:
-----
// A.d
struct C(string E ) {}

import std.typetuple;

alias I = TypeTuple!(C!K);

enum K = M;
-----
DMD version 2.066 and git crash on my system whenever I try to run dmd A.d .

GDB's backtrace:

#0  0x00000000004713da in ctfeInterpret(Expression*) ()
#1  0x000000000044e4b9 in TemplateValueParameter::matchArg(Scope*, RootObject*, unsigned long, Array<TemplateParameter*>*, Array<RootObject*>*, Declaration**) ()
#2  0x000000000045715e in TemplateDeclaration::matchWithInstance(Scope*, TemplateInstance*, Array<RootObject*>*, Array<Expression*>*, int) ()
#3  0x000000000045784d in TemplateInstance::findBestMatch(Scope*, Array<Expression*>*)::ParamBest::fp(void*, Dsymbol*) ()
#4  0x00000000004f2ce6 in overloadApply(Dsymbol*, void*, int (*)(void*, Dsymbol*)) ()
#5  0x0000000000457c97 in TemplateInstance::findBestMatch(Scope*, Array<Expression*>*) ()
#6  0x000000000045c7b9 in TemplateInstance::semantic(Scope*, Array<Expression*>*) ()
#7  0x0000000000419c54 in TypeInstance::resolve(Loc, Scope*, Expression**, Type**, Dsymbol**, bool) ()
#8  0x0000000000455ea0 in TemplateInstance::semanticTiargs(Loc, Scope*, Array<RootObject*>*, int) ()
#9  0x0000000000456a2e in TemplateInstance::semanticTiargs(Scope*) [clone .part.55] ()
#10 0x000000000045ca1b in TemplateInstance::semantic(Scope*, Array<Expression*>*) ()
#11 0x0000000000419c54 in TypeInstance::resolve(Loc, Scope*, Expression**, Type**, Dsymbol**, bool) ()
#12 0x0000000000409f4d in TypeInstance::toDsymbol(Scope*) ()
#13 0x00000000004c126e in AliasDeclaration::semantic(Scope*) ()
#14 0x0000000000407c65 in Module::semantic() ()
#15 0x0000000000404e5c in tryMain(unsigned long, char const**) ()
#16 0x00007ffff7015ab5 in __libc_start_main () from /lib64/libc.so.6
#17 0x0000000000402cf5 in _start ()
Comment 1 Ketmar Dark 2015-06-04 02:47:38 UTC
diff --git a/src/interpret.c b/src/interpret.c
index 9b358e9..bb3e2c3 100644
--- a/src/interpret.c
+++ b/src/interpret.c
@@ -730,7 +730,7 @@ Expression *ctfeInterpret(Expression *e)
         return e;
     assert(e->type);                    // Bugzilla 14642
     //assert(e->type->ty != Terror);    // FIXME
-    if (e->type->ty == Terror)
+    if (!e->type || e->type->ty == Terror)
         return new ErrorExp();

     unsigned olderrors = global.errors;
Comment 2 Kenji Hara 2015-06-04 06:08:35 UTC
This is a regression from 2.066, and a dup of issue 14642 - it's timely fixed today.

(In reply to Ketmar Dark from comment #1)
> diff --git a/src/interpret.c b/src/interpret.c
> index 9b358e9..bb3e2c3 100644
> --- a/src/interpret.c
> +++ b/src/interpret.c
> @@ -730,7 +730,7 @@ Expression *ctfeInterpret(Expression *e)
>          return e;

>      assert(e->type);                    // Bugzilla 14642
  --> This line now asserts the segfault issue won't reproduce.

>      //assert(e->type->ty != Terror);    // FIXME
> -    if (e->type->ty == Terror)
> +    if (!e->type || e->type->ty == Terror)
>          return new ErrorExp();
> 
>      unsigned olderrors = global.errors;

*** This issue has been marked as a duplicate of issue 14642 ***