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
{{ message }}
Repository navigation
STL: Non-standard non-reserved identifiers available via standard headers #2206
Describe the bug
The C++ standard allows user-defined macros to have non-reserved names. However, MSVC STL introduces some non-standard non-reserved via standard headers, which makes user-defined macros with such names able to paralyze the MSVC STL implementation.
Maybe all of them should either be removed or have their names changed to reserved identifiers in vNext.
Command-line test case
C:\Temp>type repro.cpp
#define raw_name delete // <vcruntime_typeinfo.h>, via <typeinfo>
#define xtime_get delete // <xtimec.h>, via <chrono>, <xthreads.h>, <thread>, <mutex>, <condition_variable>
#define xtime delete // same as above
#define sec delete // same as above
#define nsec delete // same as above
#define stdext delete // <xhash>, <yvals_core.h>, via <iterator>
#define hash_compare delete // <xhash>, via <unordered_map>, <unordered_set>
#define checked_array_iterator delete // <iterator>
#define unchecked_array_iterator delete // <iterator>
#define make_checked_array_iterator delete // <iterator>
#define make_unchecked_array_iterator delete // <iterator>
#define linear_congruential delete // <random>
#define subtract_with_carry delete // same as above
#define mersenne_twister delete // same as above
#define discard_block delete // same as above
#define uniform_int delete // same as above
#define uniform_real delete // same as above
#include <typeinfo>
#include <chrono>
#include <unordered_map>
#include <random>
#include <iterator>
int main()
{
}
C:\Temp>cl /EHsc /W4 /WX /std:c++17 .\repro.cpp
用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30133 版
版权所有(C) Microsoft Corporation。保留所有权利。
repro.cpp
(omitted for short)
C1003: 错误计数超过 100;正在停止编译
Expected behavior
This program should compile.
STL version
Microsoft Visual Studio Community 2019
版本 16.11.2
Additional context
The MS CRT also provides some non-standard non-reserved names (e.g. fread_s). I don't know whether such issue has been reported or how to report it.
Remove non-Standard TR1 #5763 removed TR1, including the tr1 namespace and the old <random> types linear_congruential, subtract_with_carry, mersenne_twister, discard_block, uniform_int, uniform_real.
Describe the bug
The C++ standard allows user-defined macros to have non-reserved names. However, MSVC STL introduces some non-standard non-reserved via standard headers, which makes user-defined macros with such names able to paralyze the MSVC STL implementation.
The list of names may be incomplete:
<exception>and<yvals_core.h>:stdext<typeinfo>(ultimately,<vcruntime_typeinfo.h>):raw_name(<typeinfo>: non-Standard extensiontype_info::raw_name#2195)Maybe all of them should either be removed or have their names changed to reserved identifiers in vNext.
Command-line test case
Expected behavior
This program should compile.
STL version
Microsoft Visual Studio Community 2019
版本 16.11.2
Additional context
The MS CRT also provides some non-standard non-reserved names (e.g.
fread_s). I don't know whether such issue has been reported or how to report it.Fixed
xtimeand its membersec,nsec#3594 removedxtime_get,xtime,sec,nsec.tr1namespace and the old<random>typeslinear_congruential,subtract_with_carry,mersenne_twister,discard_block,uniform_int,uniform_real.<hash_map>and<hash_set>#5764 removedhash_compare.<iterator>: Removestdext::checked_array_iteratorandstdext::unchecked_array_iterator#5817 removedchecked_array_iterator,unchecked_array_iterator,make_checked_array_iterator,make_unchecked_array_iterator.