Bug 8281 – Too many error message with a failed template instantiation

Status
NEW
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-22T04:21:30Z
Last change time
2024-12-13T18:00:37Z
Keywords
diagnostic
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: dmd#17552 →

Comments

Comment #0 by bearophile_hugs — 2012-06-22T04:21:30Z
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?
Comment #1 by robert.schadek — 2024-12-13T18:00:37Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17552 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB