Annoyance with new integer promotion deprecations

Steven Schveighoffer schveiguy at yahoo.com
Tue Feb 20 14:23:46 UTC 2018


On 2/18/18 3:01 PM, Jonathan M Davis wrote:
> On Sunday, February 18, 2018 19:42:07 Johan Engelen via Digitalmars-d wrote:
>>> There are hundreds of lines I need to molest to make the
>>> compiler shut up. I won't type another line of code on my
>>> colour library until this noise is gone... I will not maintain
>>> it. I am emotionally incapable of assaulting my code with those
>>> casts.
>>
>> Using the `-transition=intpromote` compile flag is no option for
>> you?
> 
> Since that's a transition flag, it's really only a stop-gap solution. So, if
> his issue is that he doesn't like having the casts in his code as opposed to
> not wanting to deal with updating his code right now, the flag really
> doesn't help.

No, -transition=intpromote is not stopgap, it's a flag to switch 
behavior to the new way. The stopgap is simply that you need to use the 
switch to get the new behavior (eventually, you will not need the 
switch). Everyone who is receiving these warnings should address each 
one, and THEN always compile their code with -transition=intpromote. 
Then, you may actually be able to remove some of the casts.

But you will still need casts in many cases.

However, there is one case where I think even without the intpromote 
flag is sent, that only a single cast should be necessary:

byte b = byte.min;

b = cast(byte)-b;

This is the same value whether you use intpromote or not. But this 
prints the deprecation unless you do:

b = cast(byte)-cast(int)b;

Which is awful.

-Steve

P.S. yes, Walter, I created a bugzilla for this :)
https://issues.dlang.org/show_bug.cgi?id=18380


More information about the Digitalmars-d mailing list