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


--- Comment #0 from Simon <simon.buerger rwth-aachen.de> 2014-01-15 15:56:16
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



--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2014-01-15 17:15:57 PST ---
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


--- Comment #2 from hsteoh quickfur.ath.cx 2014-01-19 08:07:57 PST ---
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


--- Comment #3 from monarchdodra gmail.com 2014-01-19 08:21:08 PST ---
(In reply to comment #1)
 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


--- Comment #4 from bearophile_hugs eml.cc 2014-01-19 10:58:15 PST ---
(In reply to comment #3)

 "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



--- Comment #5 from hsteoh quickfur.ath.cx 2014-01-19 17:40:23 PST ---
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