-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!good first issueGood for newcomersGood for newcomersrangesC++20/23 rangesC++20/23 ranges
Description
Describe the bug
ranges::ssize(a) is specified to be expression-equivalent to static_cast<D>(ranges::size(a)) (for some integer-like type D), which means applying noexcept to these two expressions should produce the same result. But due to a missing noexcept-specifier, noexcept(ranges::ssize(a)) is always false on MSVC, which is non-conforming.
This can be fixed by adding a conditional noexcept-specifier to ranges::_Ssize_fn::operator(). Since D is integer-like, the cast should never throw an exception, so the noexcept-specifier only needs to mention the ranges::size call.
I think this could be a "good first issue".
Command-line test case
D:\test>type test-ssize.cpp
#include <ranges>
int a[10];
static_assert(noexcept(std::ranges::ssize(a)));
D:\test>cl /Zs /std:c++20 test-ssize.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33030 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
test-ssize.cpp
test-ssize.cpp(4): error C2607: static assertion failed
Expected behavior
no error
STL version
Microsoft Visual Studio Community 2022
Version 17.8.0 Preview 2.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!good first issueGood for newcomersGood for newcomersrangesC++20/23 rangesC++20/23 ranges