X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fbytestring%2Ftest%2Fcompile_fail-BYTESTRING-2.c;h=d4a610e250e5bb0c0d3620e11fca944dac961a18;hb=f6557ca6537bc4d37fb4be215184a632533ba4e7;hp=7ab06f82163d9cf3fe60be33a8accf20cf1e7415;hpb=8253b9dd5d279793e267ed5dfcc4c0f2cfbaeb83;p=ccan diff --git a/ccan/bytestring/test/compile_fail-BYTESTRING-2.c b/ccan/bytestring/test/compile_fail-BYTESTRING-2.c index 7ab06f82..d4a610e2 100644 --- a/ccan/bytestring/test/compile_fail-BYTESTRING-2.c +++ b/ccan/bytestring/test/compile_fail-BYTESTRING-2.c @@ -1,7 +1,15 @@ +#include "config.h" + #include #include +/* + * 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; @@ -9,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;