Am Sa., 23. Mai 2020 um 18:44 Uhr schrieb Paul Eggert <egg...@cs.ucla.edu>: > > On 5/23/20 8:55 AM, Marc Nieper-Wißkirchen wrote: > > A combination of assure and assume would be helpful: > > > > #define checked_assume(X) do { assure (X); assume (X); } while (0) > > No, because the compiler is entitled to optimize away the 'assure (X)' in this > case. I installed the attached to try to explain this better.
Sure, but not in "-O0" or "-Og" builds, I think. Or am I mistaken? But it is definitely better to make it more robust and not rely on optimization levels: #include <assert.h> #include "verify.h" #ifdef NDEBUG # define checked_assume(E) assume (E) #else # define checked_assume(E) assert (E) #endif