April 07, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=259



--- Comment #29 from Andrei Alexandrescu <andrei@erdani.com> 2013-04-07 15:03:49 PDT ---
(In reply to comment #27)
> I think we're going to have to give up on this one.

This is a bit abrupt. What was the decision process? I just shared an anecdote about a few major bugs at work caused by this exact behavior.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 07, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=259



--- Comment #30 from Walter Bright <bugzilla@digitalmars.com> 2013-04-07 15:49:14 PDT ---
(In reply to comment #29)
> This is a bit abrupt. What was the decision process? I just shared an anecdote about a few major bugs at work caused by this exact behavior.

It's been 7 years of discussion now without an answer that works. I don't think it's abrupt!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 07, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=259



--- Comment #31 from Stewart Gordon <smjg@iname.com> 2013-04-07 16:02:40 PDT ---
(In reply to comment #30)
> (In reply to comment #29)
> > This is a bit abrupt. What was the decision process? I just shared an anecdote about a few major bugs at work caused by this exact behavior.
> 
> It's been 7 years of discussion now without an answer that works. I don't think it's abrupt!

How does pull request 119 not work?

And why haven't you written a fix yourself in these 7 years - or even made a single comment on this bug until now?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 07, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=259



--- Comment #32 from Walter Bright <bugzilla@digitalmars.com> 2013-04-07 16:50:41 PDT ---
(In reply to comment #31)
> How does pull request 119 not work?

Follow the links & comments https://github.com/D-Programming-Language/dmd/pull/119

If you want to discuss that further, please post there.

> And why haven't you written a fix yourself in these 7 years - or even made a single comment on this bug until now?

I've discussed it extensively on the n.g. This isn't the only place it's come up.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=259


Andrei Alexandrescu <andrei@erdani.com> changed:

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


--- Comment #33 from Andrei Alexandrescu <andrei@erdani.com> 2013-04-07 17:24:25 PDT ---
Reopening. The entire discussion makes it obvious this needs a fix. It's critical and has 20 votes, probably more than probably any other bug. Closing this without any explanation is straight the opposite of listening to the community. Thanks.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=259



--- Comment #34 from Walter Bright <bugzilla@digitalmars.com> 2013-04-07 17:50:06 PDT ---
I don't mind if it is reopened. It's just that it's sat at the top of the "critical" bug list forever with no movement towards a solution. I'd like to get this resolved one way or another.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=259



--- Comment #35 from Andrei Alexandrescu <andrei@erdani.com> 2013-04-07 18:38:23 PDT ---
Great. Here's a solution Walter and I just discussed:

Consider a comparison a < b, a <= b, a > b, or a >= b, in which a and b are integral types of different signedness. Without loss of generality, let's consider a is signed and b is unsigned and the comparison is a < b. Then we have the following cases:

1. If a.sizeof > b.sizeof, then a < b is lowered into a < cast(typeof(a)) b. Then signed comparison proceeds normally. This is a classic value-based conversion dating from the C days, and we do it in D as well.

2. Otherwise, if a is determined through Value Range Propagation to be greater than or equal to zero, then a < b is lowered into cast(U) a < b, where U is the unsigned variant of typeof(a). Then unsigned comparison proceeds normally.

3. Otherwise, the comparison is in error. The error message may recommend using the std.traits.unsigned function, which executes a size-informed cast.

Walter, if you agree with this resolution please mark this as "preapproved".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=259



--- Comment #36 from Andrei Alexandrescu <andrei@erdani.com> 2013-04-07 18:57:27 PDT ---
Preapproved FTW! Who wants to implement this?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=259


Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|bugzilla@digitalmars.com    |nobody@puremagic.com


--- Comment #37 from Andrei Alexandrescu <andrei@erdani.com> 2013-04-07 19:05:56 PDT ---
Resetting asignee to default. If anyone wants to work on this, please assign it to yourself!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=259



--- Comment #38 from bearophile_hugs@eml.cc 2013-04-07 19:29:00 PDT ---
(In reply to comment #35)

> 3. Otherwise, the comparison is in error. The error message may recommend using the std.traits.unsigned function, which executes a size-informed cast.

This is the source of unsigned:


auto unsigned(T)(T x) if (isIntegral!T)
{
         static if (is(Unqual!T == byte )) return cast(ubyte ) x;
    else static if (is(Unqual!T == short)) return cast(ushort) x;
    else static if (is(Unqual!T == int  )) return cast(uint  ) x;
    else static if (is(Unqual!T == long )) return cast(ulong ) x;
    else
    {
        static assert(T.min == 0, "Bug in either unsigned or isIntegral");
        return cast(Unqual!T) x;
    }
}


Is it better to use template constraints there?
And isn't it better for unsigned to accept only unsigned Ts?

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