[PATCH] libstdc++: Avoid Microsoft SAL 1.0 annotation names

Nathan Myers ncm@cantrip.org
Mon Jun 1 22:29:14 GMT 2026


On 6/1/26 4:40 PM, Jonathan Wakely wrote:
> On Mon, 1 Jun 2026 at 21:34, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>>
>> On Mon, 1 Jun 2026 at 21:29, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>>>
>>> On Mon, 1 Jun 2026, 19:59 Zephyr Lykos, <git@mochaa.ws> wrote:
>>>>
>>>> These are legacy names for The Microsoft source-code annotation
>>>> language, like their newer counterparts _In_, _Out_, etc.
>>>>
>>>> MinGW avoids the conflict with libstdc++ names by prefixing "SAL" in
>>>> their no-op macros, leading some legacy codebases porting from MSVC
>>>> toolchain, namely the .NET runtime, to define their own no-op macros,
>>>> conflicting with libstdc++.
>>>
>>> Are they actually trying to be compiled with libstdc++? Is this a real problem?
>>> Can you point to any bug reports, pull requests, or anything that
>>> shows this is a real problem in practice, not just hypothetical?
>>>
>>> I'm not happy about moving away from the obvious, natural names like
>>> __in, _out, __valid etc.
>>> The trailing underscores you're proposing do not fit our naming idioms.
>>>
>>>>
>>>> LLVM libc++ also checks this in their testsuite.
>>>
>>> Libc++ is officially supported on Windows. Libstdc++ is not, except
>>> via mingw, which apparently doesn't have a problem with these names.
>>
>> Libc++ does not appear to test for '__valid', '__range' or
>> '__inner_range', which you are proposing to outlaw in libstdc++ by
>> adding them to 17_intro/names.cc
> 
> Nor __box, __delegate, __gc, ...
> 
> It looks like the only names you want to add to 17_intro/names.cc that
> libc++ tests for are:
> __allocator
> __bound
> __in
> __out
> __pre
> 
> The others are not tested for. Some of them are even used as
> identifiers in libc++ headers, e.g. __except and __range and
> __success.

__allocator seemed like it was going to be a problem.
But it looks like that name has already been avoided.
__pre and __bound are used a bit.
__in and __out are used quite a lot.

>>>> libstdc++-v3/ChangeLog:
>>>>          * include/bits/atomic_base.h: Rename __success to __success_.
>>>>          * include/bits/shared_ptr_atomic.h: Likewise.
>>>>          * include/experimental/bits/shared_ptr.h: Likewise.
>>>>          * include/std/stop_token: Likewise.
>>>>          * include/bits/basic_ios.h: Rename __except to __except_.
>>>>          * include/bits/basic_string.h: Rename __in to __in_.
>>>>          * include/bits/basic_string.tcc: Likewise.
>>>>          * include/bits/istream.tcc: Likewise.
>>>>          * include/bits/locale_facets.h: Likewise.
>>>>          * include/bits/stl_pair.h: Likewise.
>>>>          * include/experimental/bits/simd.h: Likewise.
>>>>          * include/ext/vstring.tcc: Likewise.
>>>>          * include/std/istream: Likewise.
>>>>          * include/std/tuple: Likewise.
>>>>          * include/tr1/tuple: Likewise.
>>>>          * include/tr1/utility: Likewise.
>>>>          * include/tr2/bool_set.tcc: Likewise.
>>>>          * scripts/gen_includers.pl: Likewise.
>>>
>>> This script doesn't need to be changed (it could be deleted from the
>>> repo, it was for emulating variadic templates before g++ supported
>>> them).
>>>
>>>>          * src/c++98/istream-string.cc: Likewise.
>>>>          * src/c++98/istream.cc: Likewise.
>>>
>>> Why should this be changed? Projects using our headers would not work
>>> be including the library source files.
>>>
>>>>          * testsuite/performance/27_io/ifstream_extract_chars.cc: Likewise.
>>>>          * testsuite/performance/27_io/ifstream_getline-2.cc: Likewise.
>>>
>>> And they don't include our tests either. These tests only use "__in"
>>> in comments anyway.
>>>
>>>
>>>>          * include/bits/chrono_io.h: Rename __out to __out_.
>>>>          * include/bits/locale_conv.h: Likewise.
>>>>          * include/bits/ostream.h: Likewise.
>>>>          * include/bits/ostream.tcc: Likewise.
>>>>          * include/bits/ostream_insert.h: Likewise.
>>>>          * include/bits/ostream_print.h: Likewise.
>>>>          * include/bits/print.h: Likewise.
>>>>          * include/bits/ranges_algo.h: Likewise.
>>>>          * include/bits/regex.h: Likewise.
>>>>          * include/bits/std_thread.h: Likewise.
>>>>          * include/bits/stl_algo.h: Likewise.
>>>>          * include/bits/stl_uninitialized.h: Likewise.
>>>>          * include/experimental/algorithm: Likewise.
>>>>          * include/experimental/internet: Likewise.
>>>>          * include/ext/algorithm: Likewise.
>>>>          * include/ext/pb_ds/detail/debug_map_base.hpp: Likewise.
>>>>          * include/parallel/algo.h: Likewise.
>>>>          * include/parallel/multiway_merge.h: Likewise.
>>>>          * include/parallel/set_operations.h: Likewise.
>>>>          * include/parallel/unique_copy.h: Likewise.
>>>>          * include/std/thread: Likewise.
>>>>          * include/tr1/regex: Likewise.
>>>>          * src/c++11/snprintf_lite.cc: Likewise.
>>>
>>> Source files don't need to change.
>>>
>>>
>>>>          * include/bits/parse_numbers.h: Rename __valid to __valid_.
>>>>          * include/bits/random.tcc: Rename __range to __range_.
>>>>          Rename __out to __out_.
>>>>          * include/bits/ranges_algobase.h: Rename __in to __in_.
>>>>          Rename __out to __out_.
>>>>          * include/bits/ranges_uninitialized.h: Likewise.
>>>>          * include/bits/stl_algobase.h: Likewise.
>>>>          * include/ext/random.tcc: Likewise.
>>>>          * include/std/inplace_vector: Likewise.
>>>>          * include/tr2/bool_set: Likewise.
>>>>          * include/bits/ranges_base.h: Rename __bound to __bound_.
>>>>          * include/parallel/for_each.h: Likewise.
>>>>          * include/parallel/omp_loop.h: Likewise.
>>>>          * include/parallel/omp_loop_static.h: Likewise.
>>>>          * include/parallel/par_loop.h: Likewise.
>>>>          * include/parallel/random_shuffle.h: Likewise.
>>>>          * include/parallel/workstealing.h: Likewise.
>>>>          * include/bits/regex.tcc: Rename __pre to __pre_.
>>>>          Rename __out to __out_.
>>>>          * include/bits/simd_details.h: Rename __in to __in_.
>>>>          * include/bits/simd_vec.h: Rename __range to __range_.
>>>>          * include/bits/uniform_int_dist.h: Likewise.
>>>>          * include/pstl/parallel_backend_tbb.h: Likewise.
>>>>          * include/std/span: Likewise.
>>>>          * include/bits/unicode.h: Rename __gc to __gc_.
>>>>          * include/experimental/scope: Rename __noop to __noop_.
>>>>          * include/std/charconv: Rename __valid to __valid_.
>>>>          * include/std/format: Rename __in to __in_.
>>>>          Rename __out to __out_.
>>>>          Rename __reserved to __reserved_.
>>>>          * include/std/ranges: Rename __box to __box_.
>>>>          Rename __bound to __bound_.
>>>>          Rename __inner_range to __inner_range_.
>>>>          * testsuite/std/ranges/adaptors/detail/copyable_box.cc: Rename
>>>>          __box to __box_.
>>>>          * testsuite/17_intro/names.cc: Add checks for SAL 1.0 names.
>>>>
>>>> Signed-off-by: Zephyr Lykos <self@mochaa.ws>
> 



More information about the Libstdc++ mailing list