http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59083
--- Comment #11 from Jeffrey A. Law <law at redhat dot com> --- Damn it. Tested the wrong compiler. The problem with your testcase Markus is you're simply not allowed to pass a null pointer to sprintf, memcpy and a variety of other functions. Once you execute code which attempts that, you've walked into the realm of undefined behaviour. Once you cross that boundary the compiler is allowed to do these kinds of transformations. Your testcode is fundamentally flawed in that it relies upon undefined behaviour.