summaryrefslogtreecommitdiff
path: root/test/regression/funptr2.c
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-11-12 13:42:22 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-11-12 13:42:22 +0000
commitce4951549999f403446415c135ad1403a16a15c3 (patch)
treecac9bbb2fea29fce331916b277c38ed8fe29e471 /test/regression/funptr2.c
parentdcb9f48f51cec5e864565862a700c27df2a1a7e6 (diff)
Globalenvs: allocate one-byte block with permissions Nonempty for each
function definition, so that comparisons between function pointers are correctly defined. AST, Globalenvs, and many other files: represent programs as a list of (function or variable) definitions instead of two lists, one for functions and the other for variables. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2067 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/regression/funptr2.c')
-rw-r--r--test/regression/funptr2.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/regression/funptr2.c b/test/regression/funptr2.c
new file mode 100644
index 0000000..5c31dd2
--- /dev/null
+++ b/test/regression/funptr2.c
@@ -0,0 +1,14 @@
+/* Comparisons of pointers to functions */
+
+#include <stdio.h>
+
+int f(void) { return 0; }
+int g(void) { return 1; }
+
+int main(void) {
+ printf ("f == f is %d\n", &f == &f);
+ printf ("f == g is %d\n", &f == &g);
+ /* The following is undefined behavior */
+ printf ("f + 1 == f is %d\n", ((char *) &f) + 1 == (char *) &f);
+ return 0;
+}