Clarify that CodeQL `int` `bitShiftLeft`, `bitShiftRight` and `bitShiftRightSigned` only use lowest 5 bits of argument (or adjust behavior)
- Langage dominant
- CodeQL
- Étoiles
- 10.1k
- Forks
- 2.1k
- Merge moyen
- 2 j 15 h
- PR mergées (30 j)
- 141
Description
It appears the CodeQL `int` predicates `bitShiftLeft`, `bitShiftRight` and `bitShiftRightSigned` only use the lowest 5 bits of argument. Most likely this is due to CodeQL CLI being written in Java and Java having the [same quirk](https://docs.oracle.com/javase/specs/jls/se17/html/jls-15.html#jls-15.19).
This can be seen with this query:
```codeql
select
1.bitShiftLeft(33) as l, // Expected 0
2.bitShiftRight(33) as r, // Expected 0
2.bitShiftRightSigned(33) as sr // Expected 0
```
The results are:
| l | r | sr |
| -- | -- | -- |
| 2 | 1 | 1 |
(Tested with CodeQL CLI 2.13.1)
If this behavior is intended, please mention it in the documentation of these predicates (and probably the [QL language specification](https://codeql.github.com/docs/ql-language-reference/ql-language-specification/#built-ins-for-int)), or alternatively adjust the behavior of these predicates because the current behavior is not very intuitive.
Similarly it would also be good to define how negative arguments are handled. Currently due to using only the lowest 5 bits a shift distance of -2147483647 seems to be treated as 1, which is not intuitive. Maybe for negative shift distances there should not be any result.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Exécutez la requête CodeQL fournie avec la version pertinente de CLI et comparez les résultats des décalages aux attentes indiquées. Lisez la documentation de bitShiftLeft, bitShiftRight et bitShiftRightSigned ainsi que la spécification du langage QL liée ; le travail est considéré comme terminé soit lorsque le comportement, y compris pour les distances négatives, est corrigé, soit lorsque la limitation et la sémantique sont documentées.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Domaine
- tooling
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100