www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11955] New: win32 foreach "size_t" degrades to "uint"

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

           Summary: win32 foreach "size_t" degrades to "uint"
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: monarchdodra gmail.com


--- Comment #0 from monarchdodra gmail.com 2014-01-20 04:28:24 PST ---
Originally discovered while playing with JakobOvrum's enumrate:
https://github.com/D-Programming-Language/phobos/pull/1866

I can reduce it to a simple range that returns a Tuple!(size_t, int). On
win_32, this fails:

//----
import std.typetuple, std.typecons;

alias ET = Tuple!(size_t, int);

struct S
{
    enum empty = false;
    ET front()  property;
    void popFront();
}

void main()
{
    S s; //Or replace with "somthing.enumerate()"
    foreach(i, v; s)
    {
        pragma(msg, typeof(i).stringof);
        pragma(msg, typeof(v).stringof);
    }
    foreach(size_t i, int v; s)
    {}
}
//----

Compilation output:
//----
uint
int
main.d(20): Error: cannot infer argument types
//----

I only tested this on win_32, so I don't know how the other os's (linux), or
versions (64) behave.

While I don't think it is a hugely serious bug, it is also blocker in terms of
portability.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 20 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11955


Jakob Ovrum <jakobovrum gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jakobovrum gmail.com
         Resolution|                            |INVALID


--- Comment #1 from Jakob Ovrum <jakobovrum gmail.com> 2014-01-20 04:34:43 PST
---
(In reply to comment #0)
 I only tested this on win_32, so I don't know how the other os's (linux), or
 versions (64) behave.

`size_t` is supposed to alias to `uint` for 32-bit targets, and `ulong` for 64-bit targets. See line 20 of object.di: --- alias typeof(int.sizeof) size_t; --- -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 20 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11955


Jakob Ovrum <jakobovrum gmail.com> changed:

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


--- Comment #2 from Jakob Ovrum <jakobovrum gmail.com> 2014-01-20 04:36:17 PST
---
(In reply to comment #1)
 (In reply to comment #0)
 I only tested this on win_32, so I don't know how the other os's (linux), or
 versions (64) behave.

`size_t` is supposed to alias to `uint` for 32-bit targets, and `ulong` for 64-bit targets. See line 20 of object.di: --- alias typeof(int.sizeof) size_t; ---

Nevermind, I see what the bug is now. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 20 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11955


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid
                 CC|                            |yebblies gmail.com
           Platform|x86                         |All
         AssignedTo|nobody puremagic.com        |yebblies gmail.com
            Summary|win32 foreach "size_t"      |Aliased types not accepted
                   |degrades to "uint"          |in foreach over range of
                   |                            |tuple
         OS/Version|Windows                     |All
           Severity|blocker                     |normal


--- Comment #3 from yebblies <yebblies gmail.com> 2014-01-21 01:04:02 EST ---
struct T11955(T...) { T field; alias field this; }

alias X11955 = uint;

struct S11955
{
    enum empty = false;
    T11955!(uint, uint) front;
    void popFront() {}
}

void main()
{
    foreach(X11955 i, v; S11955()) {}
}

The argument type 'X11955' has not had semantic run on it, so checking the
implicit conversion from agg.front[0] to it fails.

https://github.com/D-Programming-Language/dmd/pull/3127

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 20 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11955



--- Comment #4 from github-bugzilla puremagic.com 2014-01-20 06:55:51 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/8562076728db18639cdeabab660b902af938758d
Fix Issue 11955 - Aliased types not accepted in foreach over range of tuple

Run semantic on the type before attempting implicit conversions.

https://github.com/D-Programming-Language/dmd/commit/bc0c114df36b79e2bff2d5db66a019a51fbe7983
Merge pull request #3127 from yebblies/issue11955

Issue 11955 - Aliased types not accepted in foreach over range of tuple

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 20 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11955


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 20 2014