🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs
Article #552

C compiler trivium

#552
From: jas
Date: Thu, 22 May 1986 23:35
33 lines
1135 bytes
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!/
Technical Details
Message-ID: <271@rtech.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!nsc!amdahl!rtech!jas

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!nsc!amdahl!rtech!jas
From: jas@rtech.UUCP
Newsgroups: net.bugs,net.lang.c
Subject: C compiler trivium
Message-ID: <271@rtech.UUCP>
Date: Thu, 22-May-86 19:35:29 EDT
Article-I.D.: rtech.271
Posted: Thu May 22 19:35:29 1986
Date-Received: Sun, 25-May-86 11:40:15 EDT
Distribution: net
Organization: Relational Technology Inc, Alameda CA
Lines: 33