fix Issue 16997 - Integral promotion rules not being followed for neg…#7013
fix Issue 16997 - Integral promotion rules not being followed for neg…#7013andralex merged 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request, @WalterBright! Bugzilla references
|
|
Blocked by dlang/phobos#5646 |
6cd692b to
bd4891c
Compare
changelog/fix16997.dd
Outdated
|
|
||
| This is corrected when one of the following command line switches are used: | ||
|
|
||
| -transition=promote |
There was a problem hiding this comment.
Perhaps -transition=intpromote for a little bit more of a hint as to the meaning when users encounter the flag in makefiles/…?
eb2ab36 to
fc844e0
Compare
15f0a2d to
0ce3256
Compare
src/ddmd/dcast.d
Outdated
| case Tchar: | ||
| case Twchar: | ||
| case Tdchar: | ||
| ue.warning("integral promotion not done for `%s`, use '-transition=promote' switch or `%scast(int)(%s)`", |
|
This breaks lots of packages because this PR is using warnings instead of deprecations. This is an outdated practice from before the Also see dlang/dub#493 |
|
The new arrayop stuff you wrote breaks with this: It's a bit hard to see where that is coming from in arrayop.d - can you have a look, please? In general, the idea is to replace |
Well the existing arrayop as well as the new implementation only perform a single cast. // byte[] = -byte[];
foreach (i; 0 .. result.length)
result[i] = cast(byte)(-a[i]);// byte[] = -byte[] + byte[];
foreach (i; 0 .. result.length)
result[i] = cast(byte)(-a[i] + b[i]);There is one final cast before assigning that deals with intermediate integer promotions. |
fc788d0 to
7219cf2
Compare
|
So what's the outlook on this? Deprecate or warn? I'm okay with each seeing that each approach has been massively used by various languages. Since we're not making this language change as part of a major general language update, deprecation seems a lot more sensible. @WalterBright can you please use deprecation? |
fb78b21 to
ca7483d
Compare
…ry + - ~ expressions
ca7483d to
71403b6
Compare
|
Blocked by dlang/phobos#5793 |
|
@andralex it's using deprecation now, and is passing. |
|
Note, the changelog here didn't reflect the update to doing deprecations instead of warnings. See https://issues.dlang.org/show_bug.cgi?id=18148 |
|
This deprecation triggers on valid code and is fairly annoying. See https://issues.dlang.org/show_bug.cgi?id=20678 |
…ation expressions
Not following integral promotion rules is a serious bug. Don't pull this yet, I want to see what impact fixing this has first.