[Issue 12919] disallow implicit signed/unsigned integer conversions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 24 21:12:52 UTC 2022


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

John Hall <john.michael.hall at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |john.michael.hall at gmail.com

--- Comment #2 from John Hall <john.michael.hall at gmail.com> ---
The signed to unsigned conversions also occur before function preconditions are
run. 

import std.stdio: writeln;

void foo(uint x)
    in(x >= 0)
{
    writeln(x);
}

void main() {
    int x = -1;
    foo(x); //prints 4294967295
}

--


More information about the Digitalmars-d-bugs mailing list