www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8260] New: * used three or more times on an array inside std.format.formattedRead

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

           Summary: * used three or more times on an array inside
                    std.format.formattedRead
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



import std.format;
void main() {
    int[3] row;
    auto text = "10 20 30";
    formattedRead(text, "%(%d %)", row);
}


DMD 2.060alpha:

...\dmd2\src\phobos\std\format.d(555): Error: using * on an array is
deprecated; use *(_param_2).ptr instead
...\dmd2\src\phobos\std\format.d(566): Error: using * on an array is
deprecated; use *(_param_2).ptr instead
test.d(5): Error: template instance
std.format.formattedRead!(string,char,uint[3u]) error instantiating


Part inside formattedRead, that uses * three times:

        alias typeof(*args[0]) A;
        static if (isTuple!A)
        {
            foreach (i, T; A.Types)
            {
                (*args[0])[i] = unformatValue!(T)(r, spec);
                skipUnstoredFields();
            }
        }
        else
        {
            *args[0] = unformatValue!(A)(r, spec);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 18 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8260


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



The bug is in your code.

void main() {
    int[3] row;
    auto text = "10 20 30";
  //formattedRead(text, "%(%d %)", row);   // bad
    formattedRead(text, "%(%d %)", &row);  // OK
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 18 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8260


timon.gehr gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |timon.gehr gmx.ch
         Resolution|INVALID                     |
            Summary|* used three or more times  |* used three or more times
                   |on an array inside          |on an array inside
                   |std.format.formattedRead    |std.format.formattedRead
                   |                            |and not guarded by template
                   |                            |constraint



Phobos should catch the error with a template constraint instead of showing
confusing errors in the template body.

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