]> git.ozlabs.org Git - ccan/blobdiff - ccan/foreach/test/compile_ok-nonconst.c
foreach: more const iteration fixes.
[ccan] / ccan / foreach / test / compile_ok-nonconst.c
diff --git a/ccan/foreach/test/compile_ok-nonconst.c b/ccan/foreach/test/compile_ok-nonconst.c
new file mode 100644 (file)
index 0000000..e533a9d
--- /dev/null
@@ -0,0 +1,14 @@
+#include <ccan/foreach/foreach.h>
+#include <ccan/foreach/foreach.c>
+
+/* Iterating const over non-const pointers should work fine. */
+int main(int argc, char *argv[])
+{
+       char *p;
+       unsigned int i = 0;
+
+       foreach_ptr(p, argv[0], argv[1])
+               i++;
+
+       return i == 2 ? 0 : 1;
+}