Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[span.cons] thinks that to_address() can throw, but it can't #3534

Closed
StephanTLavavej opened this issue Dec 10, 2019 · 6 comments · Fixed by #3546
Closed

[span.cons] thinks that to_address() can throw, but it can't #3534

StephanTLavavej opened this issue Dec 10, 2019 · 6 comments · Fixed by #3546
Assignees

Comments

@StephanTLavavej
Copy link
Contributor

N4842 22.7.3.2 [span.cons]/6 and /9 say: "Throws: When and what to_address(first) throws."

But 20.10.2 [memory.syn] and 20.10.4 [pointer.conversion] require both overloads of to_address() to be noexcept:

template<class T> constexpr T* to_address(T* p) noexcept;
template<class Ptr> auto to_address(const Ptr& p) noexcept;

Therefore, [span.cons]/6 and [span.cons]/9 should be removed editorially.

@CaseyCarter
Copy link
Contributor

CaseyCarter commented Dec 10, 2019

[span.cons]/9 fails to account for the fact that last - first can potentially throw. We should probably file an LWG issue to handle all of this.

EDIT: And by "we", I probably mean "me".

jpf91 pushed a commit to D-Programming-GDC/gcc that referenced this issue Dec 11, 2019
As discussed at cplusplus/draft#3534 two
std::span constructors specify incorrect conditions for throwing
exceptions. This patch makes those constructors have correct
noexcept-specifiers that accurately reflect what can actually throw.

	(span(ContiguousIterator, Sentinel)): Add conditional noexcept.
	* include/std/span (span(ContiguousIterator, size_type)): Change
	noexcept to be unconditionally true.
	* testsuite/23_containers/span/nothrow_cons.cc: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@279206 138bc75d-0d04-0410-961f-82ee72b054a4
@CaseyCarter
Copy link
Contributor

This is now LWG 3358.

@jensmaurer
Copy link
Member

jensmaurer commented Dec 14, 2019

Looks like we can editorially replace the phrases about to_address with "Throws: Nothing.", but of course the "last-first" issue needs to be addressed non-editorially.

@jensmaurer jensmaurer self-assigned this Dec 14, 2019
jwakely added a commit to jwakely/gcc that referenced this issue Jan 14, 2020
As discussed at cplusplus/draft#3534 two
std::span constructors specify incorrect conditions for throwing
exceptions. This patch makes those constructors have correct
noexcept-specifiers that accurately reflect what can actually throw.

	(span(ContiguousIterator, Sentinel)): Add conditional noexcept.
	* include/std/span (span(ContiguousIterator, size_type)): Change
	noexcept to be unconditionally true.
	* testsuite/23_containers/span/nothrow_cons.cc: New test.

From-SVN: r279206
@burblebee burblebee reopened this Feb 12, 2020
@burblebee
Copy link
Contributor

burblebee commented Feb 12, 2020

The changes applied to fix this (in PR #3546) conflict with those approved in LWG3358 (the drafting note in LWG3358 suggests that only p6 should have been modified). I assume LWG3358 is what we really want here?

burblebee pushed a commit that referenced this issue Feb 12, 2020
[span.cons] Wording was changed by the fix to #3534 (via #3546).
@jwakely
Copy link
Member

jwakely commented Feb 12, 2020

The changes applied here fix the editorial issue that "Throws: [thing that cannot throw]" should be "Throws: Nothing.". LWG 3358 addresses the normative defect that last - first should be considered. So they do conflict, but both changes are correct 🙂

The LWG 3358 changes supersede this editorial change and are what we want.

@CaseyCarter
Copy link
Contributor

+1 to Jonathan's comments, and apologies for not rebasing the wording of LWG 3358 onto the result of the editorial change to avoid this confusion in the first place.

burblebee pushed a commit that referenced this issue Feb 14, 2020
[span.cons] Wording was changed by the fix to #3534 (via #3546).
burblebee pushed a commit that referenced this issue Feb 17, 2020
[span.cons] Wording was changed by the fix to #3534 (via #3546).
burblebee pushed a commit that referenced this issue Feb 17, 2020
[span.cons] Wording was changed by the fix to #3534 (via #3546).
burblebee pushed a commit that referenced this issue Feb 22, 2020
[span.cons] Wording was changed by the fix to #3534 (via #3546).
zygoloid pushed a commit that referenced this issue Feb 27, 2020
[span.cons] Wording was changed by the fix to #3534 (via #3546).
zygoloid pushed a commit that referenced this issue Feb 27, 2020
[span.cons] Wording was changed by the fix to #3534 (via #3546).
zygoloid pushed a commit that referenced this issue Feb 27, 2020
[span.cons] Wording was changed by the fix to #3534 (via #3546).
zygoloid pushed a commit that referenced this issue Feb 28, 2020
[span.cons] Wording was changed by the fix to #3534 (via #3546).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants