https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107790
Bug ID: 107790 Summary: -fcontracts needs to add -lstdc++exp at the end of the collect2 options Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: link-failure Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- This links OK: g++20 fail.cc -fcontracts But this doesn't: fail.cc: In function 'int f(int, int)': fail.cc:1:45: warning: unused parameter '__r' [-Wunused-parameter] 1 | int f(int x) [[pre: x > 0]] [[post r: r > 0]] | ^ The problem is that static libs need to be listed after the .o file. Test case: int f(int x) [[pre: x > 0]] [[post r: r > 0]] { return -5; } int main() { f(42); }