Am Sa., 23. Mai 2020 um 17:39 Uhr schrieb Paul Eggert <egg...@cs.ucla.edu>: > > On 5/23/20 7:36 AM, Marc Nieper-Wißkirchen wrote: > > The verify also contains a runtime check `assume', which uses > > __builtin_unreachable if available to help the compiler in optimizing > > modes. > > I wouldn't call 'assume (X)' a "runtime check". It's more an > anti-runtime-check. > > 'assume (X)' is a directive from the programmer to the compiler that X is true > so that the compiler needn't generate code to test whether X is true. This is > why 'assume' is in verify.h: it's related to static checking (in this case, > static checking done by the programmer), not dynamic checking. > > Perhaps I should add a comment to this effect....
A combination of assure and assume would be helpful: #define checked_assume(X) do { assure (X); assume (X); } while (0) In debug builds, we get assertions and can check our assumptions. In non-debug (NDEBUG) builds, we just have the compiler hints.