[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] xen: let ASSERT_UNREACHABLE() WARN() in non-debug builds
On 24.08.22 12:35, Jan Beulich wrote: On 24.08.2022 12:22, Juergen Gross wrote:Hitting an ASSERT_UNREACHABLE() is always wrong, so even in production builds a warning seems to be appropriate when hitting one.I disagree, for two reasons: This violates the implication of NDEBUG meaning ASSERT() and friends expand to no actual code. Plus if doing so This is something we can change IMHO. for ASSERT_UNREACHABLE(), why would we not do the same for ASSERT()? There are multiple reasons to have ASSERT()s. Some serve as a kind of documentation (e.g. to document that the programmer thought of a special case not being possible), or they are meant to catch hard to diagnose bugs rather early instead of letting them hit later in a situation where it wouldn't be clear what caused them. Adding a WARN() for all of these cases isn't really appropriate, especially as this might impact performance due to added tests, which isn't the case for theoretically unreachable code. There's a reason we have ASSERT() and friends and, independently, WARN_ON() / BUG_ON() et al. We might want to introduce something like ASSERT_OR_WARN(). I'm sure this could be useful in some cases. Juergen Attachment:
OpenPGP_0xB0DE9DD628BF132F.asc Attachment:
OpenPGP_signature
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |