<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63151>63151</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang does not detect narrowing conversion with const ref
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
estan
</td>
</tr>
</table>
<pre>
Clang compiles
```cpp
struct A { A(const unsigned &x) {} };
int main(void) {
A a { -1 };
return 0;
}
```
without emitting any diagnostic, but GCC emits
```
test.cpp: In function ‘int main()’:
test.cpp:4:14: error: narrowing conversion of ‘-1’ from ‘int’ to ‘unsigned int’ [-Wnarrowing]
4 | A a { -1 };
|
```
I think it is correct to treat the program as ill formed in this case, but I'm not sure.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEU91ymzwQfZrlZsceIZm_Cy6w_fmbPEGvhSRALUgeaUmat-8Ix3HSZtoZRoB295yjPVoZox2dMS0URyjOmVxp8qE1kaTLeq9f29Ms3YjKL1c7mwjsDKx7W0t2e9T1etuJFFZF2CFUR-yA18q7SLi6jUQj8PIn8CaFoTojVGcQx4-Q1hEu0jrg9bO3-p67xRARO5Qb9i7_VJxCwdAaHLIHYnX-TedHphdLk18JzWKJrBtRulfUVo7OR7IK-An7lfD_02lL-frgt18ykfapB6LDJ4fD6hRZ7xD-41AzaOoPpwLe3LcbEN0fAAcQXZ4WNCH4kD6cDMG_2M0E92xCTNh-eMDv8ndIHIJfPhE_QuQfgXdHPmVAcdx9e6eD4vzo7gGhOuE_LMCU9JeePyFN1v1AS2gjKh-CUZR0UTCSkCaD1-DHIBeUEe084-DDsqlMlRGVjObuzBPwakHnCeMazD7TrdCNaGRm2rysS1ZWrC6zqa2KfigLIYVgnB0GcVCNZsLo2vRCc64z23LGBStZmRdFzcq9GriuFDvoIu9lyRUcmFmknffz_LzsfRgzG-Nq2lLkRZ7NsjdzvM9PaFPSrl_HCAc220jxUUaWZvM2UNqbuKnXhlIXvnQ5XVK8zVAwQ7aGuZ2IrjHdHH4BfhktTWu_V34Bfkk8b6_dNfjvRhHwy6Y1Ar9scn8FAAD__6pyJG8">