<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64077>64077</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
MinGW-clang: Converting constructor of class with no-unqiue-address members overwrites last byte with zeroes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang,
platform:windows
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
crtrott
</td>
</tr>
</table>
<pre>
While implementing `mdspan` I ran into an issue during MinGW CI. I reproduced this standalone on GodBolt: https://godbolt.org/z/KK8aj5bs7
The related change revision is found here: https://reviews.llvm.org/D154367
Shortish version, you have something like this:
```c++
template<class T, class M, class A>
class mdspan {
public:
mdspan() = default;
mdspan(const mdspan&) = default;
mdspan(T* ptr_, M map_, A acc_):ptr(ptr_),map(map_),acc(acc_) {}
template<class OT, class OM, class OA>
mdspan(const mdspan<OT, OM, OA>& other):ptr(other.ptr), map(other.map), acc(other.acc) {}
[[no_unique_address]] T* ptr;
[[no_unique_address]] M map;
[[no_unique_address]] A acc;
};
```
If you now do `mdspan<const T, M2, A2>(mdspan<T, M1, A1>);` where M1, A1 and A2 are empty, but M2 is not, and A1->A2 happens via a conversion operator in A1, not a converting constructor in A2 the last byte of `ptr` gets zeroed out.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVEFv4zgP_TX0hUjg0LHjHHxwk8mgGBQ9fAXmWMgWE2s-W_JIcoLOr19ITtPMdnewQBBT1CP59CRSOKdOmrmC_AHyfSIm3xlbtdZb433SGPlWfe9Uz6iGseeBtVf6hFCkg3Sj0FCk-IhWaFTaGwxf5yZGOdmAe1L663fcPS4DiEdr5NSyRN8ph84LLUVvNKPR-NXIB9N7yGrsvB8dZDXQAehwMrIxvV8aewI6_AI6fPtWih954zaQ7iGt5_-XjtFyLzxLbDuhT2F5Vk6ZQAmPZtISO7b8uULA8cUt-_48XMvsV_k6K34r8L_OWK9ch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