Issue 15317 - Segfault in Type::kind() with DMD v2.069.0
Summary: Segfault in Type::kind() with DMD v2.069.0
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: No Owner
URL:
Keywords: ice, pull
Depends on:
Blocks:
 
Reported: 2015-11-11 11:35 UTC by ZombineDev
Modified: 2016-01-03 14:02 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description ZombineDev 2015-11-11 11:35:03 UTC
I currently don't have time to reduce the issue, so I am posting the full source code:

// Writes a numbered table of contents with in-page links of markdown file.
import std.stdio : File, writeln;
import std.file : readText;
import std.ascii : isAlphaNum, isWhite, toLower;
import std.algorithm : countUntil, each, filter, find, findSplit,
       joiner, map, splitter, stripRight;
import std.array : replaceLast, replace;
import std.range : chain, drop, front, tee;
import std.string;
import std.conv : to;

void main()
{
   enum indent = "   ";

   uint lastLvl = 1;
   uint lvl = 1;
   uint titleNum = 1;

	File("markdown_test.md")
		.byLine
		.filter!(line => line.startsWith("#"))
      .tee!((line)
         {
            auto currLvl = countUntil!(ch => ch.isAlphaNum)(line, "#");
            titleNum = (currLvl == lastLvl)? titleNum + 1 : 1;
            lastLvl = cast(uint)currLvl;
         })
      .map!(line => line.stripRight('#'))
      .map!(line => line.replaceLast("#", titleNum.to!string ~ "."))
      .map!(line =>
            line.find(".").drop(1).front.isWhite?
            line :
            line.replace(".", ". "))
      .map!(line => line.replace("#", indent))
      .map!((line)
            {
               auto split = line.findSplit(". ");
               auto escaped = split[2]
                  .filter!(ch => ch.isAlphaNum || ch.isWhite)
                  .map!(ch => ch.toLower)
                  .to!string
                  .strip
                  .splitter!(ch => ch.isWhite)
                  .joiner("-");

               return chain(
                  split[0], split[1],
                  "[", split[2].strip, "]",
                  "(#", escaped, ")"
               );
            })
      .each!(line => line.writeln);
}
Comment 1 ZombineDev 2015-11-11 11:38:03 UTC
When I run DMD with dmd -c this_file.d
I get an compile-time error message (which is expected) and then DMD segfaults.
Comment 3 github-bugzilla 2015-11-15 12:07:57 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/0c8415056e801d414222bc6f2cf7a15e6d2a2c7a
fix Issue 15317 - Segfault in Type::kind() with DMD v2.069.0

`TypeExp.semantic` should return `ErrorExp` if the `type` is `Terror`.

https://github.com/D-Programming-Language/dmd/commit/2c3a160e10367f4750e06694779e78a9de81be1d
Merge pull request #5265 from 9rnsr/fix15317

Issue 15317 - Segfault in Type::kind() with DMD v2.069.0
Comment 4 github-bugzilla 2016-01-03 14:02:26 UTC
Commits pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/0c8415056e801d414222bc6f2cf7a15e6d2a2c7a
fix Issue 15317 - Segfault in Type::kind() with DMD v2.069.0

https://github.com/D-Programming-Language/dmd/commit/2c3a160e10367f4750e06694779e78a9de81be1d
Merge pull request #5265 from 9rnsr/fix15317