www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 567] New: Compiler crash with conflicting templates

reply d-bugmail puremagic.com writes:
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)


-- 
Nov 18 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=567






Spec is wrong, will fix spec. Shouldn't crash.


-- 
Nov 30 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
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





DMD no longer crashes with version 0.176, but the spec remains incorrect.


-- 
Dec 03 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=567


smjg iname.com changed:

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





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


-- 
Dec 11 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=567


bugzilla digitalmars.com changed:

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





Fixed DMD 0.176


-- 
Dec 12 2006