(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
pr78973-2.c
       1  /* PR c/78973 - warning: ‘memcpy’: specified size exceeds maximum object
       2     size [-Wstringop-overflow=]
       3  
       4     This is a companion test for the bug above that verifies that the correct
       5     range of the int variable is detected.
       6  
       7     { dg-do compile }
       8     { dg-require-effective-target int32plus }
       9     { dg-options "-O2 -Walloc-size-larger-than=4" }  */
      10  
      11  void *p;
      12  
      13  static void f (int n)
      14  {
      15    if (n <= 4)
      16      p = __builtin_malloc (n);
      17    /* { dg-warning "argument 1 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size 4" "ilp32" { target *-*-* } .-1 } */
      18  }
      19  
      20  void g (unsigned n)
      21  {
      22    if (n < 5)
      23      n = 5;
      24    f (n);
      25  }