On 07/30/2014 11:39 PM, Walter Bright wrote:
On 7/30/2014 2:21 PM, Timon Gehr wrote:
Because the compiler does not seem know that 'assert' never returns,
they shove
in an __assume after it.

The critical bit of misunderstanding here is the C standard *requires*
that assert be implemented as a macro,

There is no such misunderstanding. I know this.

and that NDEBUG will totally disable it.

The example implementation based on NDEBUG there does not provide this, rather, NDEBUG leaves the optimizer hint in.

Microsoft needed to add a builtin feature so that the
correct assert semantics can be reliably obtained by the optimizer.
...

What makes the second implementation with both assert and __assume there 'correct'? Does the C standard specify undefined behaviour if the assert expression has side-effects?

It's a mistake to infer from that that assert and assume are different.

I don't need to rely on the MSVC++ compiler to see this. (But the __assume they have can be used to pass hints to the optimizer even if it does not happen in the context of an assertion, which I think was bearophile's point.)

Reply via email to