Bug 2216 – bad code generation for static arrays of zero length static arrays
Status
RESOLVED
Resolution
FIXED
Severity
trivial
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2008-07-10T16:07:00Z
Last change time
2014-02-24T15:31:34Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
tomas
Comments
Comment #0 by tomas — 2008-07-10T16:07:39Z
simple test case:
int[0][10] arr;
printf("%u\n", &arr[9] - &arr[0]);
Output: Floating point exeption
The crash happens due to the pointer subtraction dividing by size 0:
AST: (&arr[9] - &arr[0]) / 0
this should just print a 0.
Comment #1 by tomas — 2008-07-11T13:53:18Z
Marking as trivial. Just return zero if stride==0.