You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe that all of our _NATIVE_WCHAR_T_DEFINED logic needs to be audited. When we're separately compiling the STL, wchar_t is always a real type, and we additionally need to provide unsigned short counterparts (so we should detect whether we're building the STL). But when headers are being used to compile user code, users with real wchar_t should see only wchar_t for character-ish things, never unsigned short. (Users with fake wchar_t will see only wchar_t being a typedef for unsigned short, as they should.)
In theory, this should not affect ABI compatibility, although it may affect source compatibility (if users with real wchar_t somehow took a dependency on the unsigned short machinery).
Because the STL grudgingly supports
/Zc:wchar_t-
(see #212), we occasionally need to detect_NATIVE_WCHAR_T_DEFINED
.For a correct (although weird) example, the STL always defines
numeric_limits<wchar_t>
:STL/stl/inc/limits
Lines 460 to 461 in 6b0238d
Then if
wchar_t
is a real type, it additionally definesnumeric_limits<unsigned short>
:STL/stl/inc/limits
Lines 685 to 688 in 6b0238d
This is backwards, but it works. Users with real
wchar_t
get both specializations, while users with fakewchar_t
get only one.However, the STL appears to have incorrect logic elsewhere. It follows the
numeric_limits
pattern forchar_traits
:STL/stl/inc/xstring
Lines 265 to 275 in 6b0238d
But when
wchar_t
is a real type,char_traits<unsigned short>
doesn't make any sense!<fstream>
has many similar examples.basic_ifstream
is always constructible fromconst wchar_t*
:STL/stl/inc/fstream
Lines 823 to 824 in 6b0238d
And when
wchar_t
is real, it's also constructible fromconst unsigned short*
:STL/stl/inc/fstream
Lines 850 to 852 in 6b0238d
I believe that all of our
_NATIVE_WCHAR_T_DEFINED
logic needs to be audited. When we're separately compiling the STL,wchar_t
is always a real type, and we additionally need to provideunsigned short
counterparts (so we should detect whether we're building the STL). But when headers are being used to compile user code, users with realwchar_t
should see onlywchar_t
for character-ish things, neverunsigned short
. (Users with fakewchar_t
will see onlywchar_t
being a typedef forunsigned short
, as they should.)In theory, this should not affect ABI compatibility, although it may affect source compatibility (if users with real
wchar_t
somehow took a dependency on theunsigned short
machinery).Also tracked by Microsoft-internal VSO-387426 / AB#387426.
The text was updated successfully, but these errors were encountered: