Thread overview
[Issue 567] New: Compiler crash with conflicting templates
Nov 18, 2006
d-bugmail
Nov 30, 2006
d-bugmail
[Issue 567] Example in spec uses conflicting templates
Dec 03, 2006
d-bugmail
Dec 12, 2006
d-bugmail
Dec 12, 2006
d-bugmail
November 18, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=567

           Summary: Compiler crash with conflicting templates
           Product: D
           Version: 0.174
          Platform: PC
               URL: http://www.digitalmars.com/d/templates-revisited.html
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-valid-code, rejects-valid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: deewiant@gmail.com


The code below is directly from the "Specialization" section in the spec, with only empty template bodies and aliases added to make it syntactically valid. Evidently (according to the spec and the comments) this should work, so there shouldn't be a conflict:

template Foo(T) {}
template Foo(T:T*) {}
template Foo(T, T) {}
template Foo(T, U) {}
template Foo(T, U:int) {}

alias Foo!(long)       a; // picks Foo(T)
alias Foo!(long[])     b; // picks Foo(T), T is long[]
alias Foo!(int*)       c; // picks Foo(T*), T is int
alias Foo!(long,long)  d; // picks Foo(T, T)
alias Foo!(long,short) e; // picks Foo(T, U)
alias Foo!(long,int)   f; // picks Foo(T, U:int)
alias Foo!(int,int)    g; // ambiguous - Foo(T, T)
                          // or Foo(T, U:int)

DMD crashes on the above after emitting the following:

asdf.d(4): template asdf.Foo(T,U) conflicts with asdf.Foo(T) at asdf.d(1)


-- 

November 30, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=567





------- Comment #1 from bugzilla@digitalmars.com  2006-11-30 03:28 -------
Spec is wrong, will fix spec. Shouldn't crash.


-- 

December 03, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=567


deewiant@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |511
              nThis|                            |
           Severity|major                       |normal
           Keywords|ice-on-invalid-code         |
           Priority|P2                          |P4
            Summary|Compiler crash with         |Example in spec uses
                   |conflicting templates       |conflicting templates




------- Comment #2 from deewiant@gmail.com  2006-12-03 04:01 -------
DMD no longer crashes with version 0.176, but the spec remains incorrect.


-- 

December 12, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=567


smjg@iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com
           Keywords|                            |diagnostic




------- Comment #3 from smjg@iname.com  2006-12-11 20:35 -------
Under DMD 0.174:

bz567.d(4): template bz567.Foo(T,U) conflicts with bz567.Foo(T) at bz567.d(1)
bz567.d(3): Error: parameter 'T' multiply defined

So it's Foo(T, U) and Foo(T, T) that conflict.  But the fact that it mentions
bz567.Foo(T) and line 1 looks like a bug.  Commenting out every line except 3
or 4 gives the similar

bz567.d(4): template bz567.Foo(T,U) conflicts with bz567.Foo(T,T) at bz567.d(3)
bz567.d(3): Error: parameter 'T' multiply defined


-- 

December 12, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=567


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #4 from bugzilla@digitalmars.com  2006-12-12 04:14 -------
Fixed DMD 0.176


--