Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/gcc.dg/Wstringop-overflow-31.c @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 1830386684a0 |
children |
line wrap: on
line source
/* PR middle-end/93646 - confusing -Wstringop-truncation on strncat where -Wstringop-overflow is expected { dg-do compile } { dg-options "-O2 -Wall" } */ extern __SIZE_TYPE__ strlen (const char*); extern char* strncat (char*, const char*, __SIZE_TYPE__); char a[4]; void f0 (char *d, const char *s) { strncat (d, s, strlen (s)); // { dg-warning "specified bound depends on the length of the source argument" } /* { dg-message "function 'f0'.*inlined from 'f1'" "inlining stack" { target *-*-* } 0 } */ // Prevent f0 from being replaced by g0. *d = 'f'; } void f1 (const char *s) { f0 (a, s); } static void g0 (char *d, const char *s) { strncat (d, s, strlen (s)); // { dg-warning "specified bound 3 equals source length" } /* { dg-message "function 'g0'.*inlined from 'g1'" "inlining stack" { target *-*-* } 0 } */ // Prevent g0 from being replaced by f0. *d = 'g'; } void g1 (void) { g0 (a, "123"); }