[CMake] Tests with assert and Release build type

Magnus Therning magnus at therning.org
Thu Dec 24 07:46:08 EST 2015


David Cole writes:

> Not only is it possible ... it WILL happen if you use the Microsoft
> C++ compiler and try to mix and match Release and Debug compilation
> units.
>
> The MS compiler has some very nice memory tracking facilities built
> into the Debug runtime libraries, but it is accomplished via different
> structs for Debug and Release builds with extra stuff in the Debug
> structs.

> So allocations from a Debug compilation unit will not be accessed
> correctly in a linked-in Release compilation unit when a pointer to it
> is passed across the boundary.
>
> You will see access violations and hard crashes happening in builds
> from the Microsoft compiler unless you ensure that everything in a
> build has matching Debug/Release defines and compiler settings.
>
> It is only safe to mix-n-match if all calls which cross a boundary
> between compilation units have NO differences in their struct and
> class definitions from an ABI perspective. Since it is difficult to
> verify when this is the case (in general) for large C++ projects, it's
> best to avoid mixing and matching...

I'm *not* mixing stuff built with `-g` and stuff built without it.  I'm
also *not* mixing linking with debug- and non-debug libraries.

I'm only mixing stuff build with `-DNDEBUG` and stuff built without it.

/M

--
Magnus Therning              OpenPGP: 0x927912051716CE39
email: magnus at therning.org   jabber: magnus at therning.org
twitter: magthe               http://therning.org/magnus

Software isn't finished until the last user is dead.
    -- head on FLOSS Weekly
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151224/982edb6a/attachment-0001.sig>


More information about the CMake mailing list