RFR: 5038439: Warning message for literal shift amounts outside the canonical domain [v2]

Archie Cobbs acobbs at openjdk.org
Mon Nov 3 18:36:35 UTC 2025


On Mon, 3 Nov 2025 16:44:13 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

>> Archie Cobbs has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 10 commits:
>> 
>>  - Merge branch 'master' into JDK-5038439 to fix conflict.
>>  - Address review comment (combine switch cases).
>>  - Merge branch 'master' into JDK-5038439 to fix conflict.
>>  - Add "long" as a supported message parameter type.
>>  - Use "bit(s)" instead of "bits" where value could be 1.
>>  - Merge branch 'master' into JDK-5038439
>>  - Sprinkle more variety into the regression test.
>>  - Minor diff cleanup.
>>  - Update "lossy-conversions" description in compiler module Javadoc.
>>  - Warn for bit shifts using an out-of-range shift amount.
>
> make/jdk/src/classes/build/tools/intpoly/FieldGen.java line 631:
> 
>> 629:                 + (params.getBitsPerLimb() - 1) + ";");
>> 630:         if (params.getBitsPerLimb() * params.getNumLimbs() != params.getPower()) {
>> 631:             result.appendLine("@SuppressWarnings(\"lossy-conversions\")");
> 
> Do you know what is the specific problematic code generated here?

Actually this goes away after merging int the latest master. It was fixed independently by JDK-8368301.

> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java line 4055:
> 
>> 4053:             int maximumShift;
>> 4054:             switch (((OperatorSymbol)operator).opcode) {
>> 4055:             case ByteCodes.ishl:
> 
> Nit: use "modernized" switch - multiple case labels and `->`?

We can combined the labels, but since we're setting _two_ values we can't use the `->` syntax. Fixed in 8044632727d.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27102#discussion_r2487476213
PR Review Comment: https://git.openjdk.org/jdk/pull/27102#discussion_r2487476095


More information about the compiler-dev mailing list