https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115434
Bug ID: 115434
Summary: Post contracts are ignored on functions with no return
statement.
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: iains at gcc dot gnu.org
Target Milestone: ---
This applies to void functions and coroutines (which usually have a return
object but do not have a return statement).
e.g:
void foo (const int b) pre ( b == 9 ) // contract checked
{}
int main()
{
foo(3);
}
void foo (const int b) post ( b == 9 ) // contract not checked
{}
int main()
{
foo(3);
}
int foo (const int b) post ( b == 9 ) // contract checked
{
return 1;
}
int main()
{
foo(3);
}
======
I was expecting the original function body to be wrapped in a try/finally block
with the post function as the cleanup. Same back to 13.3 so it does not appear
to be a regression.