Skarmander <(E-Mail Removed)> writes:

> Ben Pfaff wrote:

>> char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]

>> ={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x1f6},*p=

>> b,x,i=24;for(;p+=!*p;*p/=4)switch(x=*p&3)case 0:{return 0;for(p--;i--;i--)case

>> 2:{i++;if(1)break;else default:continue;if(0)case 1utchar(a[i&15]);break;}}}

>

> This code invokes undefined behavior by accessing b[7]. Here's a

> possible fix:

>

> char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]

> ={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p

> ,i=24;for(p=b;p+=!*p;*p/=4)switch(*p&3)case 0:{return 0;for(p--;i--;i--)case 2

> :{i++;if(1)break;else default:continue;if(0)case 1utchar(a[i&017]);break;}}}
Excellent spotting. I've been posting that sig for years and no

one's ever noticed before. Certainly I hadn't.

Your fix is fine, of course. Here is a different one that

introduces a small amount of additional misdirection:

char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]

={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p

=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+

2:{i++;if(i)break;else default:continue;if(0)case 1

utchar(a[i&15]);break;}}}

--

"The expression isn't unclear *at all* and only an expert could actually

have doubts about it"

--Dan Pop