<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/74001>74001</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
memset doesn't initialize the padding bytes of float3
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:codegen
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ahatanak
</td>
</tr>
</table>
<pre>
$ cat test.c
```
#include <string.h>
typedef __attribute__((__ext_vector_type__(3))) float float3;
float3 make_float3(float x, float y, float z) {
float3 r;
memset(&r, 0, sizeof(float3));
r.x = x;
r.y = y;
r.z = z;
return r;
}
```
The size of float3 is 16-bytes and the padding bytes should be set to zero, but they aren't.
$ clang -S -o - test.c -Os -emit-llvm
```
define <3 x float> @make_float3(float noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #0 {
%4 = insertelement <3 x float> undef, float %0, i64 0
%5 = insertelement <3 x float> %4, float %1, i64 1
%6 = insertelement <3 x float> %5, float %2, i64 2
ret <3 x float> %6
}
```
This makes it impossible to compare buffers of float3 objects byte-wise.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMlEHPmzgQhn-NuYxAxgZCDhy-9muue9i9I4OH4K2xI9t0k_z6FYY0RI2qSsgJg-fhZeYdC-_V2SA2pPxCys9EzGG0rhGjCMKI70ln5a0hrIBeBAjoQ9YT-knoB6nodq23jCvT61kiEP7VB6fMORsJ_7Y9jmu4XVDiAG0rQnCqmwO2LWE1YXXb4jW0P7AP1rXLvviAE3ZcLxi0FWFdOeFf9tg1CJP4ju22gdXr_ithX7fU2_PvfQGSwwaBjQruJxdgwsljiNoqt2TSZfHqjnZ40B_qnlkuuwLhn3B9id1i7PYSu8fYfR_DMDuzE0EOn29L_c-IUQjY4aFcecirtLsF9CCMhDAiXISUypxhjfrRzlpCh-AxQLBwR2eXT-rmsGy_gXBoCDuEbF_a2HktzBnSvyG1kMJmAkj_8pDipEKq9Y_prVCJgzLRDxyuq1TCvwEp6LtWGTubxRyElfTZql00fxtlSy-17YVuZ2PEhLIVUjogjNN9jwkri1hzZTy6gBonNOEXcZH7fNFDjKoKoDtU-Qeo5Y0vpPxBynek6s9I5QuJPUhsIzl8m1X93kkPPykfh8eDCqCmi_VedRoXl_R2ugiH0M3DgM7vLGe7f7EPPtor_U95zBLZcHnkR5Fgkx9ozuuC13UyNj3rhx47LApRCd6VdS_LY1UzOnBW9QVNVMMo43nOKWNFxeqMsmPJRZdLKiT27EgKipNQOlu8lll3TpT3MzaHgtI80aJD7eMJxlh0K-EfvZV4XhzNlmPNNUtm2s1nTwqqlQ_-yQoqaGzWiQdp0cc5AGVUUEIvk_brPP0sRDI73YwhXDzhH4SdCDudVRjnLuvtRNgpTsf6k16cXYpG2CnK94Sd4hf8HwAA__8OHaJf">