Question Details

No question body available.

Tags

c++ gcc c++26

Answers (1)

May 27, 2026 Score: 2 Rep: 9,704 Quality: Low Completeness: 80%

Currently it seems that Assumptions and Contracts are orthogonal features, so I don't think you can force compiler optimizations by e.g. using pre(expr) instead of [[assume(expr)]]. In p2900r14 under 2.3 Features Not Proposed:

The ability to assume that an unchecked contract predicate would evaluate to true and to allow the compiler to optimize based on that assumption, i.e., the assume semantic

is explicitly mentioned. If anything, the paper mentions that contracts can prevent time-travel optimizations, so this feature seems to be more about safety rather than performance.

Though I have seen some social media posts about C++26 Contracts "giving optimization power", as of today I didn't find any confirmation in official documents.

If I had to guess, selecting ignore evaluation semantics has the biggest optimization potential.