summaryrefslogtreecommitdiff
path: root/exp-sgcheck/tests/tricky.c
diff options
context:
space:
mode:
Diffstat (limited to 'exp-sgcheck/tests/tricky.c')
-rw-r--r--exp-sgcheck/tests/tricky.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/exp-sgcheck/tests/tricky.c b/exp-sgcheck/tests/tricky.c
new file mode 100644
index 00000000..624f9e4a
--- /dev/null
+++ b/exp-sgcheck/tests/tricky.c
@@ -0,0 +1,20 @@
+
+#include <stdlib.h>
+
+int main(void)
+{
+ // When I had n-u --> u, this gave a false positive... can happen because
+ // p+up can give n if you are (un)lucky, because the result is close enough
+ // to zero.
+ int u[20];
+ int* p = malloc(sizeof(int) * 100);
+ int* n;
+ int* x;
+
+ p[0] = 0; // ok
+ n = (int*)((long)p + (long)u); // result is n, because near zero!
+ x = (int*)((long)n - (long)u); // x == p
+ x[0] = 0; // ok, originally caused false pos.
+
+ return 0;
+}