Thread overview
[Issue 4252] New: [CTFE]: No array bounds checking in assignment to char[] array
May 30, 2010
Don
May 30, 2010
Walter Bright
May 31, 2010
BCS
May 30, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4252

           Summary: [CTFE]: No array bounds checking in assignment to
                    char[] array
           Product: D
           Version: 2.041
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: clugdbug@yahoo.com.au


--- Comment #0 from Don <clugdbug@yahoo.com.au> 2010-05-30 08:05:01 PDT ---
This code shouldn't compile, due to the array bounds error. But instead, compiler memory corruption occurs.

int bug4252()
{
    char [] s = "abc".dup;
    s[5] = 'd';
    return 3;
}
static assert(bug4252());

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 30, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4252


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2010-05-30 16:31:20 PDT ---
http://www.dsource.org/projects/dmd/changeset/507

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 31, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4252


BCS <shro8822@vandals.uidaho.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |shro8822@vandals.uidaho.edu


--- Comment #2 from BCS <shro8822@vandals.uidaho.edu> 2010-05-30 17:47:12 PDT ---
The revision that fixed this also fixed a missing line number bug. Looking at the source, it did so by calling a error function with a Loc value rather than without it. My question is why the original function even exists? When would the compiler ever need to dump an error message and not have a line number to attach to it?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------