]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Fix up gcc.dg/analyzer/ice-pr124375-1.c for 32-bit targets [PR124375]
authorJakub Jelinek <jakub@redhat.com>
Fri, 13 Mar 2026 13:11:57 +0000 (14:11 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 13 Mar 2026 13:11:57 +0000 (14:11 +0100)
On Wed, Mar 11, 2026 at 08:51:03PM -0400, David Malcolm wrote:
>       * gcc.dg/analyzer/ice-pr124375-1.c: New test.

Unfortunately this test FAILs on i686-linux (and guess all
other sizeof (int) == sizeof (__PTRDIFF_TYPE__) targets).

The problem is that on x86_64-linux the warning is indeed emitted on the
  __printf_buffer_offset = __printf_buffer_spec /* { dg-warning "stack-based buffer over-read" } */
line but on i686-linux (or x86_64-linux with -m32) on the
                               : step0_jumps[' '];
line.  I think the difference is due to a useless cast missing on the latter
(int and __PTRDIFF_TYPE__ are either the same or uselessly compatible, so
there is no extra cast stmt which holds some particular location).
On lp64 the above is (int)(__print_buffer_spec ? &&do_form_unknown - &&do_form_unknown
: (__PTRDIFF_TYPE__) step0_jumps[' ']);

So, either we would need to expect this dg-warning for say lp64 only and
expect a dg-warning on the other line for ilp32 (but what to do for
non-lp64/ilp32 targets?), or limit the test to lp64 only, or the following
patch just forces it onto one line (we regularly go over the 80 line limit
in the testsuite, often by a lot) and then it really doesn't matter on which
column the warning is emitted.

Tested on x86_64-linux and i686-linux by making sure the pre r16-8019
still ICEd on it (both 64-bit and 32-bit) and that latest trunk warns
on the right line with both.

2026-03-13  Jakub Jelinek  <jakub@redhat.com>

PR analyzer/124375
* gcc.dg/analyzer/ice-pr124375-1.c (__printf_buffer): Put the whole ?:
expression on a single line.

gcc/testsuite/gcc.dg/analyzer/ice-pr124375-1.c

index 537f51345a40665583d6a7880f5e01ee71ee38b7..3c1eac18dfe9777befc8bd47a89da4e0a302abc0 100644 (file)
@@ -6,9 +6,8 @@ void *__printf_buffer_ptr;
 void __printf_buffer() {
   int step0_jumps[] = {&&do_flag_hash - &&do_form_unknown};
 do_flag_hash:
-  __printf_buffer_offset = __printf_buffer_spec /* { dg-warning "stack-based buffer over-read" } */
-                               ? &&do_form_unknown - &&do_form_unknown
-                               : step0_jumps[' '];
+  __printf_buffer_offset
+    = __printf_buffer_spec ? &&do_form_unknown - &&do_form_unknown : step0_jumps[' ']; /* { dg-warning "stack-based buffer over-read" } */
   __printf_buffer_ptr = &&do_form_unknown + __printf_buffer_offset;
   goto *__printf_buffer_ptr;
 do_form_unknown: