Boost logo

Boost :

Subject: Re: [boost] Boost and (Microsoft's) _SECURE_SCL
From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2010-11-03 13:02:50


[Martin B.]
> (Which, as an aside, doesn't yield too much, as the real showstopper
> is the - independent! - _HAS_ITERATOR_DEBUGGING macro and that is
> only active in debug builds anyway.)

HID (which, among other things, takes locks) is much more expensive than SCL, but HID is also much more useful than SCL. That's why in VC10, HID (now named IDL=2) is still enabled by default in debug mode (and still cannot be enabled in release mode).

> In Visual Studio 2010, the situation is reversed, as Microsoft decided
> to now default to _SECURE_SCL=0. That means the people who change it to
> 1 in their release build for additional security will be bitten by the
> problem.

I can confidently predict that almost nobody will do that.

> (Or not, as it seems that they added some link-time checks in
> VS2010 to detect mismatches regarding the _ITERATOR_DEBUG_LEVEL. [9])

Yes. VC10's linker deterministically detects IDL mismatch and emits hard errors, naming the offending object files. (This machinery, #pragma detect_mismatch, is available for anyone to use. It will also detect when object files using the C++ Standard Library and compiled with different major versions of VC are mixed together, as long as both are VC10+; unfortunately we can't detect mixing when VC9 or earlier is involved.)

Note that there are 5 possible modes:

Release SCL=0 (now IDL=0, default in VC10)
Release SCL=1 (now IDL=1, default in VC8/9)

Debug HID=0 SCL=0 (now IDL=0)
Debug HID=0 SCL=1 (now IDL=1)
Debug HID=1 SCL=1 (now IDL=2, default in VC8/9/10)

(The HID and SCL macros are still supported for backwards compatibility, but they are immediately mapped to IDL, which is what the rest of our headers now refer to.)

Stephan T. Lavavej
Visual C++ Libraries Developer


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk