diff options
| author | David Malcolm <dmalcolm@redhat.com> | 2020-01-15 15:55:11 -0500 | 
|---|---|---|
| committer | David Malcolm <dmalcolm@redhat.com> | 2020-01-17 08:26:14 -0500 | 
| commit | 5f0303833d542b273da33e4b149974e739d350e5 (patch) | |
| tree | 654638109512ff4a9b180ab18d7bc6f786dc96cc /libcpp/expr.c | |
| parent | e5e07b68187b9aa334519746c45b8cffc5eb7e5c (diff) | |
| download | gcc-5f0303833d542b273da33e4b149974e739d350e5.zip gcc-5f0303833d542b273da33e4b149974e739d350e5.tar.gz gcc-5f0303833d542b273da33e4b149974e739d350e5.tar.bz2  | |
analyzer: fix handling of negative byte offsets (v2) (PR 93281)
Various 32-bit targets show failures in gcc.dg/analyzer/data-model-1.c
with tests of the form:
  __analyzer_eval (q[-2].x == 107024); /* { dg-warning "TRUE" } */
  __analyzer_eval (q[-2].y == 107025); /* { dg-warning "TRUE" } */
where they emit UNKNOWN instead.
The root cause is that gimple has a byte-based twos-complement offset
of -16 expressed like this:
  _55 = q_92 + 4294967280;  (32-bit)
or:
  _55 = q_92 + 18446744073709551600; (64-bit)
Within region_model::convert_byte_offset_to_array_index that unsigned
offset was being divided by the element size to get an offset within
an array.
This happened to work on 64-bit target and host, but not elsewhere;
the offset needs to be converted to a signed type before the division
is meaningful.
This patch does so, fixing the failures.
gcc/analyzer/ChangeLog:
	PR analyzer/93281
	* region-model.cc
	(region_model::convert_byte_offset_to_array_index): Convert to
	ssizetype before dividing by byte_size.  Use fold_binary rather
	than fold_build2 to avoid needlessly constructing a tree for the
	non-const case.
Diffstat (limited to 'libcpp/expr.c')
0 files changed, 0 insertions, 0 deletions
