3133 – Compiler does not check that static array casts are legal

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3133 - Compiler does not check that static array casts are legal
Summary: Compiler does not check that static array casts are legal
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords: accepts-invalid, patch
Depends on:
Blocks:
Reported: 2009年07月03日 18:48 UTC by Jarrett Billingsley
Modified: 2014年03月01日 00:36 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Jarrett Billingsley 2009年07月03日 18:48:28 UTC
When doing casts on dynamic arrays, invalid casts (i.e. where the sizes of the source and destination arrays do not have a 0 remainder) are correctly diagnosed as an error:
short[] x = [1];
int[] y = cast(int[])x; // error, array cast misalignment
The equivalent operation performed on static arrays should be diagnosable at compile-time, but isn't:
short[1] x = [1];
int[1] y = cast(int[1])x; // accepted, even though illegal
writefln("%s", y[0]); // prints garbage
Comment 1 yebblies 2011年07月03日 01:41:51 UTC
https://github.com/D-Programming-Language/dmd/pull/201 


AltStyle によって変換されたページ (->オリジナル) /