[Development] Disavowing the Lakos Rule for Q_ASSERT
Thiago Macieira
thiago.macieira at intel.com
Mon Aug 26 19:56:53 CEST 2024
The Lakos Rule says that methods that only methods with wide contracts should
be noexcept. That is, if your method has a precondition, it should not be
noexcept.
This is apparently predicated on the fact that the preconditions will be
implementable as C++ contracts some time in the future and that some compilers
or compilation modes may turn contract verifications into runtime checks.
Moreover, said checks can be implemented by throwing an exception indicating a
contract violation. Alternatively, an application could replace the Qt
assertion handler with one that throws (which is currently not possible
because qt_assert is noexcept, therefore this replacement is not supported).
I'd like to request Qt code not obey that rule. In my opinion, it's a defect
in the contract implementation rather than on Qt code. The *pre* condition
indicates something that must be true before the method is called and
therefore the method's own noexcept specification does not apply *yet*.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Principal Engineer - Intel DCAI Platform & System Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5152 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20240826/2b33e1a5/attachment-0001.bin>
More information about the Development
mailing list