]> git.ozlabs.org Git - ccan/blobdiff - ccan/bytestring/test/compile_fail-BYTESTRING-2.c
Makefile: fix random pattern hack.
[ccan] / ccan / bytestring / test / compile_fail-BYTESTRING-2.c
index 3c62f94173d354ed41364d3a26b48850a15c7737..d4a610e250e5bb0c0d3620e11fca944dac961a18 100644 (file)
@@ -4,6 +4,12 @@
 
 #include <ccan/bytestring/bytestring.h>
 
+/*
+ * BYTESTRING() can only be used safely on a literal string (or,
+ * strictly, something whose size can be determined with ARRAY_SIZE().
+ * This checks that it correctly fails to compile if used on a
+ * non-array pointer.
+ */
 int main(int argc, char *argv[])
 {
        struct bytestring bs;
@@ -11,6 +17,8 @@ int main(int argc, char *argv[])
 
 #ifdef FAIL
        bs = BYTESTRING(x);
+#else
+       bs.len = 0;
 #endif
        printf("%zd %s\n", bs.len, x);
        return 0;