www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8281] New: Too many error message with a failed template instantiation

http://d.puremagic.com/issues/show_bug.cgi?id=8281

           Summary: Too many error message with a failed template
                    instantiation
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



enum n = 2;
int[n] array;
void foo(size_t x)() {
    if (array[x] < 5)
        return;
    if (x)
        foo!(x - 1)();
}
void main() {
    foo!(n - 1)();
}



DMD 2.060alpha, I think it generates too many error message:

test.d(4): Error: array index 4294967295 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967294 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967293 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967292 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967291 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967290 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967289 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967288 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967287 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967286 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967285 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967284 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967283 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967282 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967281 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967280 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967279 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967278 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967277 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967276 is out of bounds array[0 .. 2]
test.d(4): Error: array index 4294967275 is out of bounds array[0 .. 2]


(the code is fixed replacing  if(x)  with  static if(x)  ).

Also, I think the errors are generated in the first place because in this line
of code the compiler doesn't eliminate its "then" clause before trying the
successive template instantiation:

if(x) foo!(x-1)();


Is it a good idea to run that part of the optimizer before the successive
template instantiation?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 22 2012