C 'const' attribute weirdness example
authorshort <>
Mon, 9 Jul 2001 23:02:21 +0000 (23:02 +0000)
committershort <>
Mon, 9 Jul 2001 23:02:21 +0000 (23:02 +0000)
src/const_test.c [new file with mode: 0644]

diff --git a/src/const_test.c b/src/const_test.c
new file mode 100644 (file)
index 0000000..0e02842
--- /dev/null
@@ -0,0 +1,30 @@
+#include <stdlib.h>
+#include <string.h>
+
+static void func1(const char *const *array)    /* FAILURE! */
+{
+}
+static void func2(const char *      *array)    /* FAILURE! */
+{
+}
+static void func3(      char *const *array)    /* ok */
+{
+}
+static void func4(const char *string)          /* ok */
+{
+}
+
+char **static_array;
+
+int main(void)
+{
+       static_array=malloc(3*sizeof(*static_array));
+       static_array[0]=strdup("A");
+       static_array[1]=strdup("B");
+       static_array[2]=strdup("C");
+       func1(static_array);
+       func2(static_array);
+       func3(static_array);
+       func4(static_array[0]);
+       return(0);
+}