<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/109442>109442</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            -Wdangling-gsl does not work consistently with span across STL
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          marco-antognini-sonarsource
      </td>
    </tr>
</table>

<pre>
    I'm checking the behavior of Clang 19 vs 18 and I noticed that @hokein's https://github.com/llvm/llvm-project/pull/99622 introduces some nice warnings thanks to the added attributes on `std::span`.

However, it does not work with libc++.

Here is an example:
```cpp
#include <span>
#include <string>

struct SpanAggr {
  std::span<char const> sv;
};

void test() {
  // No issue raised in 18.1
  // Issue raised from 19.1 thanks to https://github.com/llvm/llvm-project/pull/99622
  // but not with libc++
  SpanAggr a1{std::span<char const>{std::string{}}};
}
```
https://godbolt.org/z/Yfe78nsdb

IIUC, the problem boils down to the fact `std::span` is defined with a template specialization for dynamic extent and the `ClassTemplatePartialSpecializationDecl` does not get the `PointerAttr`:

```cpp
namespace std {
inline constexpr size_t dynamic_extent = -1;
template <typename _Tp, size_t _Extent = dynamic_extent>
class span;

template <typename _Tp, size_t _Extent>
struct span {
  // Bla
};
template <typename _Tp>
struct span<_Tp, dynamic_extent> {
  // Bla
};
}  // namespace std
```


https://godbolt.org/z/nh1j4a7xE


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVd1u4zYTfRr6ZmBDohzJutBFbMf4AnwoFkiKolcBRY4kbihSIEd2kqcvaDmOnc22WxQg6B8Oz_ycM0MRgm4tYsVu1uxmOxMjdc5XvfDSzYUl11pt9Tw4K3xwo5c4q516re4ZL3qQHcpnbVugDqHGTuy18-Aa2BhhW0hL2AdIVyCsgnuwjrREBdQJArZMOveM2jJeBOiIhsCyW8Z3jO9aTd1YL6TrGd8Zs3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