www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11416] New: Array and slice assignment causes garbage values

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

           Summary: Array and slice assignment causes garbage values
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: daniel350 bigpond.com


--- Comment #0 from daniel350 bigpond.com 2013-11-01 18:56:54 PDT ---
void main() {
    float[3] x = [1,1,1];
    float[] y = [4,4,4,4];

    float[5] w = x[] + y[]; //ok
    writeln(w); // [5, 5, 5, 4, 5.60519e-45]
}

w should be [5, 5, 5, 4, float.init]

Right?
http://dpaste.dzfl.pl/fork/53b6d5b5

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 01 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11416


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com
           Severity|normal                      |enhancement


--- Comment #1 from monarchdodra gmail.com 2013-11-02 02:55:56 PDT ---
 x[] + y[]; //ok
First: This is already wrong, and should lead to an Error from druntime. Unfortunalty, since druntime is compiled in release mode, you don't trigger it: http://d.puremagic.com/issues/show_bug.cgi?id=8650 Second: "float[5] w = ..." well... ditto. If the array lengths don't match, it's wrong behavior. Conclusion: The program is wrong, but since druntime is in release, you don't get an error, so you see undefined behavior. It would have been nice if it had errored out, but didn't. You can always try it re-compiling druntime in non-release: you'll see it error. Changing this to ER: Should throw an error, or should be able to chose non-release druntime by default. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 02 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11416



--- Comment #2 from daniel350 bigpond.com 2013-11-02 20:03:44 PDT ---
The correctness of the language shouldn't be reliant on the runtime...

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