On 8/4/15 5:39 PM, Jonathan M Davis wrote:

I'm certainly not opposed to have a message be printed before the HLT
instruction with assert(0), but I don't at all agree that the fact that
the message is not seen in -release is a reason not to have a message.

For instance:

https://github.com/D-Programming-Language/druntime/blob/master/src/core/time.d#L2283

This makes it seem like a message will be printed in the case where ticksPerSecond was 0. but in reality it simply throws a segfault.

Whether this happens or not in debug mode is pretty much irrelevant -- druntime is used in release mode by the vast majority of all developers, and this passes unit tests for us. It's the whole impetus for this thread, because someone actually did find a case where it gets there.

So why have a message with the clock name that failed? Why not just assert(0)? The only purpose I see for such a message is to trick the reviewer into accepting it (not that this was the intention of course) as being sufficiently explanatory when an error occurs.

We should always review such code with the view that when it *doesn't* print the message, is the error sufficient to a user such that they know where to look. I find it hard to believe it's *ever* sufficient, if you needed to have a message in the first place.

We can look at it this way -- if you need to add a message to an assert(0) for it to make sense, you should find a different way to communicate that.

-Steve

Reply via email to