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

[libc++] Invalid copy-construction from span<Incomplete> #104496

Closed
ldionne opened this issue Aug 15, 2024 · 0 comments · Fixed by #104500
Closed

[libc++] Invalid copy-construction from span<Incomplete> #104496

ldionne opened this issue Aug 15, 2024 · 0 comments · Fixed by #104500
Assignees
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@ldionne
Copy link
Member

ldionne commented Aug 15, 2024

The following code fails on libc++ but works with other implementations:

#include <span>

struct Bar;

void foo(std::span<Bar> a) {
  std::span<Bar> b(a);
}

The problem seems to be that we try testing for the range-based constructor of span, which hard-errors because we are checking the contiguous_range constraint and end up performing arithmetic on a pointer to an incomplete type.

Repro: https://godbolt.org/z/ox6dajefE

@ldionne ldionne added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Aug 15, 2024
@ldionne ldionne added this to the LLVM 19.X Release milestone Aug 15, 2024
@ldionne ldionne self-assigned this Aug 15, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage in LLVM Release Status Aug 15, 2024
ldionne added a commit to ldionne/llvm-project that referenced this issue Aug 15, 2024
Trying to copy-construct a std::span from another std::span holding
an incomplete type would fail as we evaluate the SFINAE for the
range-based constructor. The problem was that we checked for
__is_std_span after checking for the range being a contiguous_range,
which hard-errored because of arithmetic on a pointer to incomplete
type.

As a drive-by, refactor the whole test and format it.

Fixes llvm#104496
@github-project-automation github-project-automation bot moved this from Needs Triage to Done in LLVM Release Status Aug 16, 2024
llvmbot pushed a commit to llvmbot/llvm-project that referenced this issue Aug 16, 2024
Trying to copy-construct a std::span from another std::span holding an
incomplete type would fail as we evaluate the SFINAE for the range-based
constructor. The problem was that we checked for __is_std_span after
checking for the range being a contiguous_range, which hard-errored
because of arithmetic on a pointer to incomplete type.

As a drive-by, refactor the whole test and format it.

Fixes llvm#104496

(cherry picked from commit 99696b3)
tru pushed a commit to llvmbot/llvm-project that referenced this issue Aug 19, 2024
Trying to copy-construct a std::span from another std::span holding an
incomplete type would fail as we evaluate the SFINAE for the range-based
constructor. The problem was that we checked for __is_std_span after
checking for the range being a contiguous_range, which hard-errored
because of arithmetic on a pointer to incomplete type.

As a drive-by, refactor the whole test and format it.

Fixes llvm#104496

(cherry picked from commit 99696b3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
Development

Successfully merging a pull request may close this issue.

1 participant