GCC-9, those retards finally fixed something for once!!!

So I was just checking out the new gcc-9 release and I discovered something to my surprise. They have done something exceedingly rare, they have actually fixed one of their many insane long-standing code-gen bugs which have caused me major aggravation for years.

This particular bug was introduced in gcc 4.8 (according to compiler explorer). The specifics of this bug relates to the use of post-increment when dereferencing a pointer. The compiler in its infinite insanity would perform the increment before reading the value at the pointer address.

char ch = *p++;               // as part of a loop
incl	%ecx                  // generated assembly
movb	-1(%ecx), %al         // seriously WTF

GCC-9 appears to have finally have fixed this, the increment now happens after the memory read, as it should. How the hell did this bug last for so long without any complaints as far as I could find. Am I the only one who ever actually looks at the generated assembly.



This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *