RFR: 8371162: Compiler warns about implicit cast from long to int in shift operation [v4]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Feb 4 11:14:31 UTC 2026


On Tue, 3 Feb 2026 17:13:19 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 4004:
>> 
>>> 4002:                               owntype);
>>> 4003:             switch (tree.getTag()) {
>>> 4004:             case SL_ASG, SR_ASG, USR_ASG -> { }     // we only use (at most) the lower 6 bits, so any integral type is OK
>> 
>> It's true that there's no loss of precision. One possible thing we might want to do (low priority) is to issue a lint warning if we see a constant value that exceeds the max shift amount.
>
>> It's true that there's no loss of precision. One possible thing we might want to do (low priority) is to issue a lint warning if we see a constant value that exceeds the max shift amount.
> 
> Indeed... but I think that should already be taken care of (separately) by [JDK-5038439](https://bugs.openjdk.org/browse/JDK-5038439) (PR #27102), no?

Ha! I missed that. Great!

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28180#discussion_r2763463780


More information about the compiler-dev mailing list