This isn't true - at least not in general. It totally depends what 'my_supper_assert_macro()' expands into, and what the expanded code does. If it doesn't terminate before 'ptr' is dereferenced, your program will face UB just like it always did. On top of that, the expanded code may be different in every TU. This is obviously IF-NDR but also the sad reality.
Today's
void fun(Foo* ptr) {
my_supper_assert_macro (ptr!=nullpter);
my_supper_assert_macro(ptr->hasData());
}should not have any problems, ever
so replacing this blindly againstvoid fun(Foo* ptr) {
contract_assert (ptr!=nullpter);
contract_assert(ptr->hasData());
}does not work, as I understand, since observe could be a problem?
(I know now that when using pre I have to re-write with &&)
The same reasoning applies to all contract assertions, not only 'pre()'.
~Dani
/Harald
_______________________________________________ SG15 mailing list SG15@lists.isocpp.org https://lists.isocpp.org/mailman/listinfo.cgi/sg15