https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86842
Bug ID: 86842 Summary: Allow run-time checks of pre- and postconditions Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: fiesh at zefix dot tv Target Milestone: --- Preface: A rather hard-to-find set of bugs is that introduced by violating run-time preconditions imposed by certain functions. For example, failing to satisfy the Compare requirement for std::sort can lead to tricky problems ranging from segmentation faults to programs just running fine and sometimes doing something not quite expected. It would be great if there was a means to activate run-time assertions on these preconditions, as well as on postconditions. In terms of http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0788r3.pdf , everything listed as "Expects:" and "Ensures:" could be checked by a run-time check. Since in general checking a sentence with n universal quantifiers will result in O(N^n) many operations, it might be meaningful to separate those by different macros, allowing the user control over the amount of complexity degradation they allow for their debug build. In addition, checks whose complexity is within the algorithm's complexity class already might be enabled in Debug Mode Lite by default. (This extends https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60519 )