www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8843] New: Statically known slices given as fixed-size array arguments

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

           Summary: Statically known slices given as fixed-size array
                    arguments
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



void foo(ref int[4] data) {}
void bar(in ref int[4] data) {}
void main() {
    auto a = new int[10];
    foo(a[0 .. 4]);
    bar(a[0 .. 4]);
}



dmd 2.061alpha shows that currently that code is not accepted:

test.d(5): Error: function test.foo (ref int[4u] data) is not callable using
argument types (int[])
test.d(5): Error: cannot implicitly convert expression (a[0u..4u]) of type
int[] to int[4u]
test.d(6): Error: function test.bar (ref const(int[4u]) data) is not callable
using argument types (int[])
test.d(6): Error: cannot implicitly convert expression (a[0u..4u]) of type
int[] to const(int[4u])

But I think that code is worth accepting, when the slice width is known at
compile-time.

See also Issue 8838

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 17 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8843


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |DUPLICATE



*** This issue has been marked as a duplicate of issue 3652 ***

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