www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24655] New: `inout` breaks invalid `bool` to non-`bool`

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

          Issue ID: 24655
           Summary: `inout` breaks invalid `bool` to non-`bool` conversion
                    checks
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: qs.il.paperinik gmail.com

With the nightly DMD, the following are accepted without deprecation or error
(the first fails without `-dip1000`):
```d
ref inout(ubyte) asUbyte(return ref inout(bool) x)  safe => *cast(inout ubyte*)
&x;
inout(ubyte)* asUbyte(return inout(bool)* x)  safe => cast(inout ubyte*) x;
inout(ubyte)[] asUbyte(return inout(bool)[] x)  safe => cast(inout ubyte[]) x;
```

Remove `inout` manually and the deprecation warnings appear as expected:
```d
ref ubyte asUbyte(return ref bool x)  safe => *cast(ubyte*) &x;
ubyte* asUbyte(return bool* x)  safe => cast(ubyte*) x;
ubyte[] asUbyte(return bool[] x)  safe => cast(ubyte[]) x;
```

--
Jul 09