(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
tree-ssa/
builtin-sprintf-29.c
       1  /* PR middle-end/100732 - ICE on sprintf %s with integer argument
       2     { dg-do compile }
       3     { dg-options "-O2 -Wall -fdump-tree-optimized" } */
       4  
       5  #define sprintf(d, f, ...) \
       6    __builtin___sprintf_chk (d, 0, 32, f, __VA_ARGS__)
       7  
       8  
       9  void fi (int i, const char *s)
      10  {
      11    sprintf (i, "%s", s);       // { dg-warning "\\\[-Wint-conversion" }
      12  }
      13  
      14  void gb (char *d, _Bool b)
      15  {
      16    sprintf (d, "%s", b);       // { dg-warning "\\\[-Wformat" }
      17  }
      18  
      19  void gi (char *d, int i)
      20  {
      21    sprintf (d, "%s", i);       // { dg-warning "\\\[-Wformat" }
      22  }
      23  
      24  void gd (char *d, double x)
      25  {
      26    sprintf (d, "%s", x);       // { dg-warning "\\\[-Wformat" }
      27  }
      28  
      29  
      30  struct X { int i; };
      31  
      32  void gx (char *d, struct X x)
      33  {
      34    sprintf (d, "%s", x);       // { dg-warning "\\\[-Wformat" }
      35  }
      36  
      37  
      38  /* Also verify that the invalid sprintf call isn't folded to strcpy.
      39     { dg-final { scan-tree-dump-times "sprintf_chk" 5 "optimized" } }
      40     { dg-final { scan-tree-dump-not "strcpy" "optimized" } } */