1330 – Array slicing does not work the same way in CTFE as at runtime

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1330 - Array slicing does not work the same way in CTFE as at runtime
Summary: Array slicing does not work the same way in CTFE as at runtime
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 critical
Assignee: No Owner
URL:
Keywords: wrong-code
: 3456 4057 5907 (view as issue list)
Depends on:
Blocks: 4050 4051
Show dependency tree / graph
Reported: 2007年07月10日 21:34 UTC by Jarrett Billingsley
Modified: 2014年02月16日 15:24 UTC (History)
4 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 2007年07月10日 21:34:50 UTC
Example:
char[] Something(char[] blah)
{
	char[] slice = blah[0 .. 1];
	slice[0] = 'h';
	return blah;
}
void main()
{
	pragma(msg, Something("foo".dup));
	writefln("%s", Something("foo".dup));
}
When compiled, this displays "foo"; when run, "hoo". Notice that slicing the input array and then modifying the slice is supposed to modify the original array, but it doesn't in CTFE because Slice() in the frontend always creates a copy of the data.
Comment 1 Don 2009年12月29日 00:12:38 UTC
*** Issue 3456 has been marked as a duplicate of this issue. ***
Comment 2 Don 2010年04月03日 11:20:23 UTC
*** Issue 4057 has been marked as a duplicate of this issue. ***
Comment 4 Don 2011年05月06日 01:48:15 UTC
*** Issue 5907 has been marked as a duplicate of this issue. ***


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