Skip to content

Commit e1bf977

Browse files
committed
Make array example run
1 parent 6b43013 commit e1bf977

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

spec/expression.dd

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,23 +1080,17 @@ $(H3 $(LNAME2 cast_array, Arrays))
10801080
as a type paint, with the array length adjusted to match any change in
10811081
element size. If there's not a match, a runtime error is generated.)
10821082

1083-
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
1084-
---
1085-
import std.stdio;
1086-
1087-
int main()
1088-
{
1083+
$(SPEC_RUNNABLE_EXAMPLE_RUN
1084+
---
10891085
byte[] a = [1,2,3];
1090-
auto b = cast(int[])a; // runtime array cast misalignment
1086+
//auto b = cast(int[])a; // runtime error: array cast misalignment
10911087

10921088
int[] c = [1, 2, 3];
10931089
auto d = cast(byte[])c; // ok
10941090
// prints:
10951091
// [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0]
10961092
writeln(d);
1097-
return 0;
1098-
}
1099-
---
1093+
---
11001094
)
11011095

11021096
$(DDOC_SEE_ALSO $(RELATIVE_LINK2 cast_array_literal, Casting array literals).)

0 commit comments

Comments
 (0)