aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/pr109577.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/analyzer/pr109577.c')
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr109577.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr109577.c b/gcc/testsuite/gcc.dg/analyzer/pr109577.c
new file mode 100644
index 0000000..a6af6f7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr109577.c
@@ -0,0 +1,16 @@
+void *malloc (unsigned long);
+
+double *
+unsafe (unsigned long n)
+{
+ return malloc (n * sizeof (double));
+}
+
+double *
+safer (unsigned long n)
+{
+ unsigned long nbytes;
+ if (__builtin_mul_overflow (n, sizeof (double), &nbytes))
+ return 0;
+ return malloc (nbytes);
+}