On 8/22/20 3:30 AM, Bruno Haible wrote:
-#if _GL_HAS_BUILTIN_UNREACHABLE + features such as function calls not inlined by the compiler. */ + +#if _GL_HAS_BUILTIN_ASSUME +/* Use a temporary variable, to avoid a clang warning + "the argument to '__builtin_assume' has side effects that will be discarded" + if R contains invocations of functions not marked as 'const'. */ +# define assume(R) \ + ((void) ({ __typeof__ (R) _gl_verify_temp = (R); \ + __builtin_assume (_gl_verify_temp); })) +#elif _GL_HAS_BUILTIN_UNREACHABLE # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
This is OK, but please also mention in the comment that __builtin_assume generates better code for Clang 8 than __builtin_unreachable does, as that's the only reason to put up with all this mess.