<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/88234>88234</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`__builtin_clz` produces different results if argument is a function call returns 0
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bi6c
</td>
</tr>
</table>
<pre>
```
#include <stdio.h>
int w;
int s;
int f() {
return 0;
}
void main() {
s = __builtin_clz(f());
w = s && 4;
printf("The value of s is: %d\n", s); // output: The value of s is: 31
/***********************/
w = (s = __builtin_clz(f())) && 4;
printf("The value of s is: %d\n", s); // output: The value of s is: 30
}
```
Hi, we are using clang to compile in Ubuntu 22.04.4 LTS amd 64.
In the main function, we believe that the assignment to variable `s` would lead variable `s` to have the same value.
This also happens when the function call is replaced to a similar macro function which also returns 0.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VE1v4zYQ_TXUZRCBJmXKOuiQxDVaoLem54ASR9YUFCnww0b76wt9NGmSBfayCxCQqHnzOPPmiTpGujrElh2f2PFc6JxGH9qOVF903vzdMsX3xc-MPzIhyfU2GwQmn2My5MuRyV-2KLkEdyaf3nfxw25g4sREA6zePwIABEw5OOBvSFaft5ebJwOTJvc1LQKTZ3h97TLZRO61t_8wcdr5lyXfoPcVGoEJxYSC6n-hOZBLW5J4GRFu2mYEP0AEikw-AhNHw47PjgnBxDPEjRmYuDBxAZ_TnNOC-2ayPOznrPDHH7EuH5ti4vRdIRbdvnT-kxvnnwb5yUS_0sJ5R9ABIUdyV-itdldIHno_zWQRyMGfXXYpgxAlr8oKfn_5A_RkQFXlRvObgzTiahAYsusTebcTd2gJbwhp1GkFbT6f0KXlkJsOpDuLwBSPTHG4-2wNWNTmayx5GPXKhRD1tPe71_AyUgRt44KZZ3QR7iNudf1XEvTaWqAIAWerezQLo4ZIE1kdYNJ98O_g-0j9uDFuP0YEXhamlaaRjS6wPdQHUUsu6roY26pROAx1V2nTHLvmJCRWSjSKG9WjkrygVnBR8erAuRKVrMv60BvB60ad1IFLXrOK46TJltbeptKHa0ExZmxPJyGrwuoObVwvByEc3mENLqY4novQLjkPXb5GVnFLMcV3lkTJ4nJ7fLSm4jAHb3KPEQwNA4ZlJAFjtikCDaDDNa9jWnT9pOGbIEUOth1Tmhe7bZ68UhpzV_Z-YuKyVLE_Hubg_8I-MXFZa49MXNbe_g0AAP__aKd1ow">