www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2712] New: error with passing an array slot as another array length to new

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

           Summary: error with passing an array slot as another array length
                    to new
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: andrei metalanguage.com


void foo(uint n, in uint[] x)
{
    auto y = new uint[x[n]];
}

void main()
{
    foo(new uint[10]);
}

Error: need size of rightmost array, not type x[n]


-- 
Mar 06 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2712


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au
            Version|unspecified                 |1.00



This is a parsing error. Workaround: Adding () around the x[n] allows it to
compile.

void foo(uint n, in uint[] x) {
    auto y = new uint[ (x[n]) ];
}

void main() {
    foo(7, new uint[10]);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 27 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2712


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 783 ***

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