From: Zbigniew Jędrzejewski-Szmek Date: Thu, 11 Jul 2019 08:17:28 +0000 (+0200) Subject: Rewrite IN_SET() X-Git-Tag: v243-rc1~95^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13093%2Fhead;p=thirdparty%2Fsystemd.git Rewrite IN_SET() This restores proper speed with asan builds with gcc 9.1.1. Fixes #12997. $ rpm -q gcc gcc-9.1.1-2.fc31.x86_64 $ time ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1 UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 build-rawhide-sanitize/test-conf-parser (old) 86.99s user 20.22s system 361% cpu 29.635 total (new) 3.05s user 0.29s system 99% cpu 3.377 total Size is increased a bit: $ size build/systemd (old) 1683421 246100 1208 1930729 1d75e9 build/systemd (new) 1688237 246100 1208 1935545 1d88b9 build/systemd ... but that's <0.1%, so we don't really care. --- diff --git a/src/basic/macro.h b/src/basic/macro.h index 00dfd480239..336cb3a0999 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -462,7 +462,8 @@ static inline int __coverity_check__(int condition) { * type for the array, in the hope that checkers such as ubsan don't complain that the initializers for \ * the array are not representable by the base type. Ideally we'd use typeof(x) as base type, but that \ * doesn't work, as we want to use this on bitfields and gcc refuses typeof() on bitfields.) */ \ - assert_cc((sizeof((long double[]){__VA_ARGS__})/sizeof(long double)) <= 20); \ + static const long double __assert_in_set[] _unused_ = { __VA_ARGS__ }; \ + assert_cc(ELEMENTSOF(__assert_in_set) <= 20); \ switch(x) { \ FOR_EACH_MAKE_CASE(__VA_ARGS__) \ _found = true; \