D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6295 - [Regression 2.054] Segfault in checkPurity() of template value parameter
Summary: [Regression 2.054] Segfault in checkPurity() of template value parameter
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Linux
: P2 regression
Assignee: No Owner
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2011-07-12 09:47 UTC by Puneet Goel
Modified: 2011-08-01 21:45 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Puneet Goel 2011-07-12 09:47:22 UTC
Here is a reduced test case. Compiles and runs fine with dmd-2.053, segfaults at compile stage for dmd 1.054. Compiles and runs fine with dmd-2.054 if I take out "size_t N" template parameter. Also compiles fine with 2.054 if printFoo is defined outside the main function.

import std.stdio;
struct Foo(IF, size_t N) {}
interface Bar {}
void main() {
  void printFoo(T: Foo!(IF, N), IF, size_t N)(T foo)
    if(is(IF == interface)) {
    writeln("Type: ", T.stringof);
  }
  Foo!(Bar, 1) foo;
  printFoo(foo);
}
Comment 1 bearophile_hugs 2011-07-12 10:04:10 UTC
Simplified code:


struct Foo(int N) {}
void main() {
    void bar(T: Foo!(N), int N)(T) {}
}
Comment 2 kennytm 2011-07-12 10:48:23 UTC
DMD pull #242.

https://github.com/D-Programming-Language/dmd/pull/242
Comment 3 bearophile_hugs 2011-07-12 12:11:47 UTC
(In reply to comment #2)
> DMD pull #242.
> 
> https://github.com/D-Programming-Language/dmd/pull/242

That was fast :-)

A limited form of typestate (see bug 4571 ) might help D user code avoid many null reference bugs.
Comment 4 kennytm 2011-07-12 12:17:33 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > DMD pull #242.
> > 
> > https://github.com/D-Programming-Language/dmd/pull/242
> 
> That was fast :-)
> 
> A limited form of typestate (see bug 4571 ) might help D user code avoid many
> null reference bugs.

Typestates in D cannot help NULL dereferencing bugs in DMD which is written in C++.