broadinstitute / gamgee

A C++14 library for NGS data formats
http://broadinstitute.github.io/gamgee/
MIT License
40 stars 13 forks source link

Consider using bsls::Assert or similar for multi-modal runtime assertions #251

Open droazen opened 10 years ago

droazen commented 10 years ago

Adding this library would allow us to categorize our runtime precondition checks (eg., function parameter sanity checking, etc.) by how expensive and/or critical they are, and then select at build time how much protection we want and how much runtime we're willing to devote to such checks.

BSLS_ASSERT runtime check typically enabled in safe and non-opt build modes
BSLS_ASSERT_SAFE       runtime check typically only enabled in safe build modes
BSLS_ASSERT_OPT runtime check typically enabled in all build modes

Paranoid and/or expensive-but-non-essential checks could then be isolated from critical and/or cost-free checks, and a typical gamgee build might only enable the second category.

This library also provides an automated way of verifying that the precondition checks in the "cheap" category are actually cheap, and of testing that the appropriate checks are in place in each mode.

http://bloomberg.github.io/bde/group__bsls__assert.html

MauricioCarneiro commented 10 years ago

I vouch for use of this library across our projects as long as it doesn't replace the std library as the speaker alluded to. The assertion levels are a very good way to think about this problem