Post by bob » Sat Nov 23, 2013 1:55 am

Just discovered this bug in Crafty, which worked on gcc compiler versions thru 4.7.2, but when I moved to 4.7.3 on my macbook, boom.



this is the issue:



char buffer[256] = "abcdef";



strcpy (buffer, buffer+2);



Has always worked in the past, even though the man page says "two strings should not overlap." After tracking it down, I remembered a sharp put-down by Linus Torvalds a year or two back on this subject with the glibc folks. They decided to copy right to left, for no good reason. And as he pointed out, this broke tons of programs that had used the right-to-left copy assumption. They replied, "but the man page says don't do it, so what's the problem?" He answered "because you are breaking thousands of programs that have used it for years. What's the advantage in the change? It is no faster to copy right to left than left to right (just set the direction flag). With no advantage to change, why change? just because you can doesn't cut it." Apparently they didn't listen.



I only presume this is really a glibc problem on Mavericks that was not there on Mountain Lion, although on Mountain Lion I did install gcc 4.7.2, which mac ports now avoids in favor of 4.7.3.



In any case, beware.