VSO_0000000_instantiate_iterators_misc: Suppress deprecated volatile operation warnings by YexuanXiao · Pull Request #5656 · microsoft/STL (original) (raw)

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

@YexuanXiao

At line 1596 of this file, a volatile tuple<int, int, int> is used, but utility L217 marks it as deprecated, causing the test to fail. This PR uses #define _SILENCE_CXX20_VOLATILE_DEPRECATION_WARNING to suppress the warning and allow the test to pass.

TRAIT_V(tuple_size, volatile tuple<int, int, int>);
template <class _Tuple>
struct _CXX20_DEPRECATE_VOLATILE tuple_size<volatile _Tuple> : _Tuple_size_sfinae<_Tuple> {}; // ignore cv

@YexuanXiao

StephanTLavavej

@StephanTLavavej

Interesting - why is this passing with our current compilers? Are newer versions of Clang noticing this?

Regardless, change looks like a slam dunk. ⛹️

@StephanTLavavej StephanTLavavej changed the titleSuppress the deprecated volatile operation warnings for tests/VSO_0000000_instantiate_iterators_misc VSO_0000000_instantiate_iterators_misc: Suppress deprecated volatile operation warnings

Aug 2, 2025

@YexuanXiao

Interesting - why is this passing with our current compilers? Are newer versions of Clang noticing this?

Regardless, change looks like a slam dunk. ⛹️

I believe there is a bug in MSVC where using a static member of a deprecated struct does not generate a warning, see Godbolt.

@YexuanXiao

I reported this issue on DevCom-10946291. Before MSVC fixes it, the _CXX20_DEPRECATE_VOLATILE macro had no effect.

@YexuanXiao

Bad news: MSVC can generate warnings, but enabling /w14996 or /W3 manually is required. By default, MSVC does not respect [[deprecated]].

@StephanTLavavej

Oh, I expect /W3 as an absolute minimum of effort from users (I also believe it's the IDE default). /W1 and /W2 are jokes.

@YexuanXiao

I found that even with /W3, MSVC doesn't respect the [[deprecated]] attribute of template specializations.

template struct foo_trait { static inline constexpr bool value = false; };

template struct [[deprecated]] foo_trait { static inline constexpr bool value = true; };

int main() { static_assert(foo_trait::value); }

I re-reported it as DevCom-10948908.

@StephanTLavavej

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej

⚠️ 🐈 ⚠️

Labels

test

Related to test code

2 participants

@YexuanXiao @StephanTLavavej