Important: Please read the Qt Code of Conduct -

Forcing Qt container bounds checking

  • I'd like to force Qt containers to perform bounds checks even in release mode, and I am willing to pay the performance price. There's nothing like an undetected memory overwrite to ruin your data and make your day. Better to crash...

    The way I read the code, all I need to do is define QT_FORCE_ASSERTS in my project. Since most of the really important assertions are in the container header files, I would get at least those for my uses of Qt containers.

    I am aware that

    • QT_FORCE_ASSERTS is undocumented, so it may change without notice
    • I won't get assertions for any Qt-internal use of Qt containers

    Do you have any better suggestions on how to do it in an official and documented way?

  • Lifetime Qt Champion

    @Asperamanca AFAIK, the code is highly optimized for size and speed. So beside the assertations the is no extra safety net - at least for the code I'm aware of. you can always check yourself - the sources are available after all.


Log in to reply