[Issue 3041] New: Array slices can be compared to their element type: bad codegen or ICE
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun May 31 05:58:07 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3041
Summary: Array slices can be compared to their element type:
bad codegen or ICE
Product: D
Version: 1.045
Platform: All
OS/Version: All
Status: NEW
Keywords: accepts-invalid, ice-on-invalid-code, wrong-code
Severity: major
Priority: P3
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: matti.niemenmaa+dbugzilla at iki.fi
The following invalid code is accepted by DMD 1.045:
void main() {
int[1] a = 1;
int b = 1;
assert (a[] == b);
}
The assertion fails, meaning that some nonsense code has been generated.
According to the spec the above is invalid: == isn't an array operation. Other
comparison operators like < and >= are also incorrectly accepted.
The following variation gives "Internal error: ../ztc/cgcod.c 1554":
void main() {
int[] a = [1];
int b = 1;
assert (a[] == b);
}
If the slice is removed from the assertion, making it read just "a == b",
neither example compiles, as expected:
arst.d(4): Error: incompatible types for ((a) == (b)): 'int[1u]' and 'int'
arst.d(4): Error: incompatible types for ((a) == (b)): 'int[]' and 'int'
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list