https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104635
--- Comment #6 from Szüllő Ádám <szullo.adam at gmail dot com> --- I'd bothered to read the articles, and there were no new information (nor relevant to this exact case). You are right that this is not a bug, becasue the code is invalid, as myself emphasized too in the description. This case is perfectly covered by undefined behaviour. This is why i was hesitant to open the bug report in the first place. Still, i opened it, because it felt not right, the optimizer optimized away well defined code, something that might worth a check.