gcc/gcc/testsuite/gcc.dg/pr78973.c

21 lines
472 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* PR c/78973 - warning: memcpy: specified size exceeds maximum object size
Test case for what was initially thought to be a false positive but after
deeper investigation turned out to be a true positive.
{ dg-do compile }
{ dg-options "-O2 -Wall" } */
void f (void *p, int n)
{
if (n <= 4)
__builtin_memset (p, 0, n); /* { dg-warning "exceeds maximum object size" } */
}
void g (void *d, unsigned n)
{
if (n < 5)
n = 5;
f (d, n);
}