Skip to content

VSO_0000000_instantiate_iterators_misc: Suppress deprecated volatile operation warnings#5656

Merged
StephanTLavavej merged 1 commit intomicrosoft:mainfrom
YexuanXiao:instantiate_iterators_misc
Aug 8, 2025
Merged

VSO_0000000_instantiate_iterators_misc: Suppress deprecated volatile operation warnings#5656
StephanTLavavej merged 1 commit intomicrosoft:mainfrom
YexuanXiao:instantiate_iterators_misc

Conversation

@YexuanXiao
Copy link
Contributor

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>);

STL/stl/inc/utility

Lines 616 to 617 in f015db5

template <class _Tuple>
struct _CXX20_DEPRECATE_VOLATILE tuple_size<volatile _Tuple> : _Tuple_size_sfinae<_Tuple> {}; // ignore cv

@YexuanXiao YexuanXiao requested a review from a team as a code owner July 26, 2025 09:43
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Jul 26, 2025
@StephanTLavavej
Copy link
Member

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 added the test Related to test code label Aug 2, 2025
@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews Aug 2, 2025
@StephanTLavavej StephanTLavavej changed the title Suppress 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
Copy link
Contributor Author

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
Copy link
Contributor Author

YexuanXiao commented Aug 2, 2025

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

@YexuanXiao
Copy link
Contributor Author

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

@StephanTLavavej
Copy link
Member

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.

@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Aug 7, 2025
@YexuanXiao
Copy link
Contributor Author

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

template <typename T>
struct foo_trait
{
    static inline constexpr bool value = false;
};

template <typename T>
struct [[deprecated]] foo_trait<const T>
{
    static inline constexpr bool value = true;
};

int main()
{
    static_assert(foo_trait<const int>::value);
}

I re-reported it as DevCom-10948908.

@StephanTLavavej
Copy link
Member

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

@StephanTLavavej StephanTLavavej merged commit 5255207 into microsoft:main Aug 8, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews Aug 8, 2025
@StephanTLavavej
Copy link
Member

⚠️ 🐈 ⚠️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Related to test code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants