]> pd.if.org Git - lice/blobdiff - tests/void.c
autocommit for files dated 2014-11-17 20:13:38
[lice] / tests / void.c
diff --git a/tests/void.c b/tests/void.c
new file mode 100644 (file)
index 0000000..20adc93
--- /dev/null
@@ -0,0 +1,17 @@
+// arithmetic on void
+
+int main(void) {
+    expecti(sizeof(void), 1);
+    expecti(sizeof(main), 8); // sizeof function == sizeof(&function)
+                              // i.e the function pointer for that
+                              // function (GCC extension)
+
+    int a[] = { 1, 2, 3 };
+    void *p = (void*)a;
+
+    expecti(*(int*)p, 1); p += 4;
+    expecti(*(int*)p, 2); p += 4;
+    expecti(*(int*)p, 3);
+
+    return 0;
+}