← Back to context

Comment by pjmlp

2 days ago

C++ has had bounds checking in standard library for ages, and on compiler specific frameworks like MFC and OWL, however plenty of devs apparently never read the compiler manuals on how to improve safety and related compiler settings.

It is also relatively strange that many devs use the lacks of standardisation as an excuse to not adopt safety features in C and C++, while at the same time rush out to adopt cool toys that are specific to a single compiler.

For std::string and std::vector yes, but not for std::span (until C++26) for reasons I cannot understand.

  • That is standardese, you get them all bounds checked by using specific compiler flags.

    Here is for VC++

    https://github.com/microsoft/STL/blob/2a62bf7b4079f0a3e33ec8...

    You just have to define the proper iterator level for enabling bounds checking.

    Other compilers have similar approaches.

    I chose VC++ on purpose, because it is what I know better, and is famously trailing behind C++26 features.

    Then there are the Tclass, Cclass, Qclass, from all those C++ frameworks pre C++98.

    However plenty devs seem allergic to learn about how to use their compilers.