[Issue 3468] dmd allows negative values to be assigned to an uint variable

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Nov 22 04:23:45 PST 2015


https://issues.dlang.org/show_bug.cgi?id=3468

Mathias LANG <pro.mathias.lang at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pro.mathias.lang at gmail.com
            Version|D1 (retired)                |D2
                 OS|Linux                       |All

--- Comment #2 from Mathias LANG <pro.mathias.lang at gmail.com> ---
This 'bug' is still around in D2.
It looks like an heritage from C / C++, one of the bad kind.

It allows you to write gems such as:
```
uint func (int i) { return i; }

void main ()
{
  uint v = func(-42);
}
```

@Walter: Would you be okay with the idea of deprecating this ?
Related: https://issues.dlang.org/show_bug.cgi?id=259

--


More information about the Digitalmars-d-bugs mailing list