www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24235] New: Functions 0-out single element static arrays

https://issues.dlang.org/show_bug.cgi?id=24235

          Issue ID: 24235
           Summary: Functions 0-out single element static arrays
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: isaacbunsen gmail.com

when passing a single element static array of float[1] or double[1] that
accepts multiple arguments, one will find that the argument is 0 when the
function is called. For example, the following code fails the assert. `a` is an
array of [0] no matter what is passed in. This does no happen if the second
argument is removed, or the length of the array is increased.

float test(float[1] a, float whatever) {
    return a[0];
}

unittest {
    assert(test([1.0], 1) == 1);
}

--
Nov 08 2023