https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118720

--- Comment #4 from Daniel Green <ddgreen at gmail dot com> ---
(In reply to Andrew Pinski from comment #3)
> b -= n < (uint32_t)(100000);
> 
> Can produce undefined behavior. because now you are doing `work-1` which is
> before the array.
> 
> ```
> static constexpr void foo(uint64_t n, char* b)
> {
>     uint64_t f0 = 429497 * n;
> 
>     b[0] = fd[f0 >> 32][0];
>     b[1] = fd[f0 >> 32][1];
>     b[2 - (n < (uint32_t)(100000))] = '9';
> }
> ```
> 
> Is the fix to the code.

Huh, annoying that `-fsanitize=undefined` doesn't pick up on it.

Reply via email to