[Issue 24655] New: `inout` breaks invalid `bool` to non-`bool` conversion checks

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 9 12:43:22 UTC 2024


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 at puremagic.com
          Reporter: qs.il.paperinik at 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;
```

--


More information about the Digitalmars-d-bugs mailing list