For debugging. It would be unreasonably inefficient on embedded systems
to have them compiled in.
It depends whether you consider error handling and debugging to be the same
thing. Failing an assert is not an error - it is a bug. It is very
difficult, and sometimes impossible, to contrive a useful response to
a bug. It is also not really worth the effort.
BUG_ON is a poor solution for embedded systems. When developing and debugging
you don't want your system to panic just because you are on the track of a bug.
And then when the system is in production, you don't want it to panic period.
We have had lots of situations where BUG_ON has been used incorrectly to handle
errors, and we have had to replace it with proper error-handling.
Anyone developing or doing serious testing would have debugging turned on.
Anyone doing debugging, would have debugging turned on. It seems pretty
unlikely that the assertions would bit-rot.
Selecting a config option doesn't seem that hard.
How?
Our asserts don't roll over and die. They print a message and dump the
stack and keep going.
And lots of file systems (e.g. EXT2, JFFS2) have optional prints as well,
just like UBIFS.
--