March 28, 2026
12:23 a.m.
On Sat Mar 28 00:01:53 2026 +0000, Safocl Stollmannovic wrote:
None of them deem it UB. https://godbolt.org/z/17hrvMrv4
bar(foo*, unsigned int): xor eax, eax test esi, esi mov esi, esi setne al sal eax, 16 add eax, DWORD PTR [rdi+4+rsi*4] retAs far as I understand, only one branch is used here. So, the manifestation of UB is obvious. UB is not a thing at asm level. The closest you'll get is a race condition, and even that will only corrupt the affected memory address, nothing else.
If the compilers deemed n!=0 to be UB and optimized accordingly, then the resulting asm would be `mov eax, [rdi+4]; ret` and nothing else. I have no idea what you think that second branch would do. Do you want buffer overflows to jump to `abort` or [something](https://godbolt.org/z/3dnab7d9q)? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10471#note_134188