On Thu, 2026-05-07 at 09:20 +0200, Jakub Jelinek wrote:
> On Thu, May 07, 2026 at 01:35:07PM +0800, H.J. Lu wrote:
> > I got
> > 
> > FAIL: gcc.dg/analyzer/divide-by-zero-6.c  (test for warnings, line
> > 14)
> > FAIL: gcc.dg/analyzer/divide-by-zero-6.c  at line 15 (test for
> > warnings, line 14)
> > FAIL: gcc.dg/analyzer/divide-by-zero-6.c (test for excess errors)
> > Excess errors:
> > /export/gnu/import/git/gitlab/x86-
> > gcc/gcc/testsuite/gcc.dg/analyzer/divide-by-zero-6.c:14:18:
> > warning: use of uninitialized value '*f.y' [CWE-457]
> > [-Wanalyzer-use-of-uninitialized-value]
> 
> The warnings are correct, but I guess the test wasn't meant to test
> two
> completely different thing, one on 64-bit targets and one on 32-bit
> ones.
> 
> struct foo { int x; int y; };
> 
> has sizeof (8) on most targets (except on non-32-bit int), but the
> test
> was using __builtin_memset (f, 0, sizeof (f)) where f is a pointer.
> Now, this happens to clear the whole structure on 64-bit targets but
> only
> first half of it on 32-bit ones, so on 64-bit it emits the expected
> warning
> about division by zero, while on 32-bit about using uninitialized
> value.
> 
> I think the testcase was meant to clear the whole structure on all
> arches,
> the following patch does that.
> 
> Tested on x86_64-linux -m32/-m64, ok for trunk?

Thanks, LGTM

> 
> 2026-05-07  Jakub Jelinek  <[email protected]>
> 
>       * gcc.dg/analyzer/divide-by-zero-6.c (init_foo): Use sizeof
> (*f)
>       rather than sizeof (f).
> 
> --- gcc/testsuite/gcc.dg/analyzer/divide-by-zero-6.c.jj       2026-05-06
> 17:43:14.669261648 +0200
> +++ gcc/testsuite/gcc.dg/analyzer/divide-by-zero-6.c  2026-05-07
> 09:13:54.430980976 +0200
> @@ -5,7 +5,7 @@ struct foo { int x; int y; };
>  void
>  init_foo (struct foo *f)
>  {
> -  __builtin_memset (f, 0, sizeof (f));
> +  __builtin_memset (f, 0, sizeof (*f));
>  }
>  
>  int
> 
> 
>       Jakub
> 

Reply via email to