https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107699
--- Comment #11 from Carlos Galvez <carlosgalvezp at gmail dot com> --- Consider this more realistic example: https://godbolt.org/z/jbbqbe8d9 The compiler has all the information available to ensure that getCount().get() is smaller than 3, as enforced by the class invariant which is visible to the compiler. Class invariants help us not having to check things all the time. For example gsl::not_null allows us to not have to check for nullptr on every use.