File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
java/ql/src/semmle/code/java Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -305,10 +305,6 @@ class CompileTimeConstantExpr extends Expr {
305
305
/**
306
306
* Gets the integer value of this expression, where possible.
307
307
*
308
- * All computations are performed on QL 32-bit `int`s, so no
309
- * truncation is performed in the case of overflow within `byte` or `short`:
310
- * `((byte)127)+((byte)1)` evaluates to 128 rather than to -128.
311
- *
312
308
* Note that this does not handle the following cases:
313
309
*
314
310
* - values of type `long`,
@@ -332,7 +328,10 @@ class CompileTimeConstantExpr extends Expr {
332
328
else
333
329
if cast .getType ( ) .hasName ( "short" )
334
330
then result = ( val + 32768 ) .bitAnd ( 65535 ) - 32768
335
- else result = val
331
+ else
332
+ if cast .getType ( ) .hasName ( "char" )
333
+ then result = val .bitAnd ( 65535 )
334
+ else result = val
336
335
)
337
336
or
338
337
result = this .( PlusExpr ) .getExpr ( ) .( CompileTimeConstantExpr ) .getIntValue ( )
You can’t perform that action at this time.
0 commit comments