Comment by account42
4 days ago
Will compilers be able to optimize functions based the assumtions that contracts hold (even if they aren't being checked)?
4 days ago
Will compilers be able to optimize functions based the assumtions that contracts hold (even if they aren't being checked)?
At least for this iteration of contracts, no. From the proposal (italics in original) [0]
> Features Not Proposed
> To keep the scope of this proposal minimal (while still viable), the following features are intentionally excluded from this proposal; we expect these features to be proposed as extensions at a later time, building on the foundations laid by this proposal.
> 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
Of course, that's the idea. At least my C compiler does so
Your C compiler optimizes based on C++ contracts?
C++ like contracts. but without the ending semicolon, because that would cause backward compatibility problems. https://github.com/rurban/rcc/#additional-c-features