Why does intpromote spew warnings for ~ operator?
Alexey
invalid at email.address
Mon Sep 13 06:12:10 UTC 2021
On Sunday, 12 September 2021 at 18:13:14 UTC, Walter Bright wrote:
> On 9/12/2021 7:14 AM, Steven Schveighoffer wrote:
>> Right now, the deprecation is telling users *under penalty of
>> not compiling* to do something that will achieve nothing when
>> intpromote is enabled.
>
> The question for ~x is to promote x to an int and then
> complement, or complement and then promote.. Those are not
> equivalent.
>
> The idea is to move towards doing it the C way, which is
> promote and then complement.
But is this really ok to change variable size for simple bit
flipping? maybe there should be exception at least for ~
operation?
```D
void main()
{
ushort a = 0b100;
ushort b = ~a;
}
```
```txt
t.d(5): Deprecation: integral promotion not done for `~a`, use
'-preview=intpromote' switch or `~cast(int)(a)`
```
More information about the Digitalmars-d
mailing list