summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/pr17252.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/execute/pr17252.c')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr17252.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr17252.c b/gcc/testsuite/gcc.c-torture/execute/pr17252.c
new file mode 100644
index 000000000..bd1b6b99e
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr17252.c
@@ -0,0 +1,21 @@
+/* PR 17252. When a char * pointer P takes its own address, storing
+ into *P changes P itself. */
+
+char *a;
+
+main ()
+{
+ /* Make 'a' point to itself. */
+ a = (char *)&a;
+
+ /* Change what 'a' is pointing to. */
+ a[0]++;
+
+ /* If a's memory tag does not contain 'a' in its alias set, we will
+ think that this predicate is superfluous and change it to
+ 'if (1)'. */
+ if (a == (char *)&a)
+ abort ();
+
+ return 0;
+}