Bug 663 – Slice assignment does not bounds check when it should

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2006-12-07T09:17:00Z
Last change time
2014-02-15T13:19:32Z
Assigned to
bugzilla
Creator
burton-radons

Comments

Comment #0 by burton-radons — 2006-12-07T09:17:46Z
This code compiles and executes: auto test = new char [2]; test [] = 'a'; test = test [0 .. 1]; test [0 .. 2] = 'b'; // this line should assert writef ("%s\n", test.ptr [0 .. 2]); And produces the string "bb"; at the very least it should be "ba". DMD should throw an assertion failure at runtime on the marked line when -release mode is not specified.
Comment #1 by thomas-dloop — 2006-12-10T11:05:52Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-12-07: > http://d.puremagic.com/issues/show_bug.cgi?id=663 > This code compiles and executes: > > auto test = new char [2]; > > test [] = 'a'; > test = test [0 .. 1]; > test [0 .. 2] = 'b'; // this line should assert > writef ("%s\n", test.ptr [0 .. 2]); > > And produces the string "bb"; at the very least it should be "ba". DMD should > throw an assertion failure at runtime on the marked line when -release mode is > not specified. Added to DStress as http://dstress.kuehne.cn/norun/o/opSliceAssign_04_A.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFfDkKLK5blCcjpWoRAnW6AKCYm8biE6n3M/mohIMA9x6sqMVvygCeJobM tNhnm9JW7n00U+vQLjoxaj0= =6xa1 -----END PGP SIGNATURE-----
Comment #2 by bugzilla — 2006-12-27T02:01:44Z
Fixed DMD 0.178