r/C_Programming • u/8d8n4mbo28026ulk • Aug 26 '26
Reliability Lessons From SQLite - Richard Hipp | SSW 2026
https://www.youtube.com/watch?v=V_qzqY1bb7I
39
Upvotes
r/C_Programming • u/8d8n4mbo28026ulk • Aug 26 '26
View all comments
Show parent comment
2
u/8d8n4mbo28026ulk Aug 26 '26
It is for optimisation, but it can help you catch bugs anyway: if the compiler optimises aggresively based on the assumptions it was given, it'll reveal further design flaws in your code when you test it and get back garbage.
But what is your expectation of an
assert()that fails? Turning an assertion into an error-check makes no sense. We use errors when a situation is recoverable from. If an invariant is violated, there's no way to recover from that. If you return an "error" to the caller, what's the caller supposed to do? There's nothing that can be done, except fixing the code.A safer alternative to
__builtin_assume()is to justabort(), but that can incur significant runtime overhead (4x in the case of SQLite, for example).