]> gcc.gnu.org Git - gcc.git/commit
[nvptx] Fix UB in nvptx_assemble_value
authorTobias Burnus <tobias@codesourcery.com>
Fri, 11 Sep 2020 11:57:36 +0000 (13:57 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Fri, 11 Sep 2020 11:57:36 +0000 (13:57 +0200)
commit5544bca37bc41f9e23a0ac30453e3d3cec896d38
tree43ddbef59f9918ecd22681cbbc2f9bd6ca40da94
parent7e10b6b0b34739e6735d5076cc331c7cd194be2b
[nvptx] Fix UB in nvptx_assemble_value

When nvptx_assemble_value is called with size == 16, this bitshift runs
into UB:
...
  val &= ((unsigned  HOST_WIDE_INT)2 << (size * BITS_PER_UNIT - 1)) - 1;
...

Fix this by checking the shift amount.

Tested on nvptx.

gcc/ChangeLog:

* config/nvptx/nvptx.c (nvptx_assemble_value): Fix undefined
behaviour.

(cherry picked from commit 5e044c673f8e7d473a2207cd3ba32910c4f5fc75)
gcc/ChangeLog.omp
gcc/config/nvptx/nvptx.c
This page took 0.062538 seconds and 5 git commands to generate.