Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / analyzer / pr109577.c
blob18417818b54fd6ed8ab2c5659def5e3e5b1deb88
1 /* C only: C++ exceptions cause a malloc leak after "safer" returns.
2 Therefore this test has been duplicated as
3 c-c++-common/analyzer/pr109577-noexcept.c */
5 void *malloc (__SIZE_TYPE__);
7 double *
8 unsafe (__SIZE_TYPE__ n)
10 return (double *) malloc (n * sizeof (double));
13 double *
14 safer (__SIZE_TYPE__ n)
16 __SIZE_TYPE__ nbytes;
17 if (__builtin_mul_overflow (n, sizeof (double), &nbytes))
18 return 0;
19 return (double *) malloc (nbytes); /* Exceptions enabled cause a leak here. */