0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd: Mitigate __builtin_assume w/ side-effects diagnosed (arguably incorrect) and ignored.

This commit is contained in:
Jason Volk 2023-02-08 17:24:02 -08:00
parent 8e983880f2
commit 3f82d32619

View file

@ -68,10 +68,16 @@
// //
#if !defined(assume) #if !defined(assume)
#if __has_builtin(__builtin_assume) #if __has_builtin(__builtin_assume) && defined(__cplusplus)
#define assume(x) assert(x); __builtin_assume(x); // If the expression is 'evaluated' (llvm) (which includes any
// function call not explicitly annotated pure, even when fully
// inlined) then the assume is diagnosed by -Wassume and ignored.
// Declaring the bool mitigates this.
#define assume(x) assert(x); ({ const bool y(x); __builtin_assume(y); })
#elif __has_builtin(__builtin_assume)
#define assume(x) assert(x); __builtin_assume(x)
#else #else
#define assume(x) assert(x); #define assume(x) assert(x)
#endif #endif
#endif #endif