C compiler trivium
    jas at rtech.UUCP 
    jas at rtech.UUCP
       
    Fri May 23 09:35:29 AEST 1986
    
    
  
Those with pcc-based C compilers may be surprised by the output
of the following program:
int x;
main()
{
    int *ip = &x;
    switch( (int) ip )
    {
      case &x:
	printf( "x\n" );
	break;
    
      default:
	printf( "other\n" );
	break;
    }
    exit( 0 );
}
This compiles without a complaint on a 3B5 running System V, a Microvax II
running Ultrix, and a CCI Power 6 running CCI's 4.2 port.  The output
is "other".  For a clue to what's going on, add a second global int 'y',
and insert its address as another case in the switch.
Jim Shankland
..!ucbvax!mtxinu!\
                  rtech!jas
 ..!ihnp4!cpsc6a!/
    
    
More information about the Comp.lang.c
mailing list