https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112635
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|libgcc |tree-optimization
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Yep, GCC fixes the code for you by eliding 'buf'. That's perfectly OK though
since the code invokes undefined behavior.
I'm inclined to close this as INVALID/WONTFIX, it isn't really a bug
(but also not a feature you can rely on of course).