SQLite Forum

sqlite3_step after sqlite3_finalize: what is the expected behavior?
Login
> If the documentation of sqlite3_finalize holds the truth ...

It does. The phrase "can result in undefined behavior" includes the possibility of behavior not recognized as grievous. A better phrasing might be "results in undefined behavior" (which includes not seg-faulting), but that invites the same perplexity you have shared.

> then the documentation of sqlite3_step deserves an update to avoid confusion.

I am not seeing it that way yet. What specific part of the doc you quoted for the SQLITE_MISUSE return do you believe to be false or confusing? If that return is seen, it means what is claimed. That logical (if-then) relation does not imply its converse, (which would be "If this routine is called inappropriately, then SQLITE_MISUSE will be returned.") Among the possible outcomes of an inappropriate call is a seg-fault, as is documented explicitly and is implicitly included in "undefined behavior".

At present, I am disinclined to further elaborate that documentation merely to make explicit such a result of <u>[elementary logic](https://en.wikipedia.org/wiki/Converse_(logic\) )</u>. Doing so would be in the same category as adding, to every positive assertion, something like: "This does not mean P, Q, R ... (without logical end)."