www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 663] New: Slice assignment does not bounds check when it should

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=663

           Summary: Slice assignment does not bounds check when it should
           Product: D
           Version: 0.175
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: burton-radons smocky.com


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.


-- 
Dec 07 2006
next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail puremagic.com 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-----
Dec 10 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=663


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla digitalmars.com  2006-12-27 02:01 -------
Fixed DMD 0.178


-- 
Dec 27 2006