RFR: 8280067: Incorrect code generated for unary - on char operand
Jan Lahoda
jlahoda at openjdk.java.net
Thu Jan 20 18:57:50 UTC 2022
On Thu, 20 Jan 2022 17:09:26 GMT, Vicente Romero <vromero at openjdk.org> wrote:
> I'm seeing that Lower is reducing the conditional to `(char)(char)2` at `Lower::visitConditional` could it be that the type is wrongly set to `int` somewhere before reaching to `Gen`?
I believe the types of `(char)(char) 2` is correctly `char`, and the type of `-(char)(char)2` is correctly `int` in the AST. But then, when generating the code, the actual value on the stack for `-(char)(char)2` is `-2`, but then for the outermost cast, the codegen thinks the type of the value on the stack is `char`, so does it does not need the cast (`i2c`), which is wrong.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7156
More information about the compiler-dev
mailing list