www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11932] New: alias this and sort produce wrong code

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

           Summary: alias this and sort produce wrong code
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: simon.buerger rwth-aachen.de



PST ---
When I use alias this to overload the comparison operators on a struct, sort
gives wrong results on some inputs (dmd 2.64.2, 64bit Ubuntu). Minimal example
to reproduce:

struct S
{
    int i;
    alias i this;
}

void main(string[] args)
{
    auto arr = [S(1000),S(2000)];
    arr[].sort;
    assert(arr[0] < arr[1]);
}

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




Built-in sort property cannot recognize alias this, because TypeInfo object
does not have any information about alias this. That's one of the reason why it
is planned to be deprecated.

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


hsteoh quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh quickfur.ath.cx



Workaround: use std.algorithm.sort instead of the built-in sort.

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


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com




 That's one of the reason why it is planned to be deprecated.
"Planned" ? What's the hold up? Can't we just straight up deprecate it? Or are there things that need to be done first? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 19 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11932


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc





 "Planned" ? What's the hold up? Can't we just straight up deprecate it? Or are
 there things that need to be done first?
I think there's nothing holding us back from deprecating the built-in sort. But there's something holding us back from deprecating the built-in reverse. But the two functions are separated and unrelated, to this shouldn't be a problem. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 19 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11932




I vote for deprecating the built-in sort in the next release.

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