On 05/17/2013 09:53 PM, Anton Khirnov wrote:
> A proper use for an assert is when the code following it would crash anyway if
> the assert wasn't there and the asserted condition was false. In such a case 
> the
> assert makes it much easier to track what went wrong. It can also simplify
> understanding the author's intent.

I consider this exactly an improper and dangerous use of assert().

If you know already that codepath would lead to a crash the proper
solution is to return an error to the caller.

Imagine having your browser/vnc-terminal/chat-application crash because
of a network glitch because you put an assert() in a decoding routine
(e.g. the vorbis one pointed by j-b).

The proper way is to return an error to the program and then the program
can decide what to do about it.

A library MUST not randomly crash, on purpose or not.

While developing sprinkling asserts so you can see clearly where your
assumptions fail is perfectly fine.

lu
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to