From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,53e4464b3f3000b8,start X-Google-Attributes: gid1164f8,public X-Google-Thread: fee84,53e4464b3f3000b8,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-03-25 14:28:28 PST Xref: gmd.de comp.sys.dec:14605 comp.unix.osf.osf1:2651 Path: gmd.de!xlink.net!howland.reston.ans.net!agate!msuinfo!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!dingo.cc.uq.oz.au!coates From: coates@kelvin.physics.uq.oz.au (Tony Coates) Newsgroups: comp.sys.dec,comp.unix.osf.osf1 Subject: Re: Switch failure with c89 compiler on Alpha, OSF/1.3 Date: 24 Mar 94 16:44:54 Organization: Department of Physics, The University of Queensland Distribution: world Message-ID: Reply-To: coates@physics.uq.oz.au NNTP-Posting-Host: kelvin.physics.uq.oz.au I reported earlier an apparent failure of a switch construct with DEC's `c89' compiler. It appeared that the `case -1 :' branch of the switch was not taken, and c89 took the `default :' branch instead. This did not happen using the `cc' compiler supplied with OSF/1.3. What I had overlooked, as was pointed out to me be a reply, was the type coercion of the function returning the value for the switch construct, something like sign f(void) { return -1; } switch(f()) { ... } to simplify things greatly. I forgot, in my earlier post, to describe the type `sign'. It turned out that this was an unsigned int, a mistake in the declaration of sign (which should be an int for my application). Once this declaration of `sign' was changed, the program compiled correctly under c89. I haven't yet had the chance to isolate where the coercion of -1 to an unsigned value causes the failure (though of course, no compiler should be expected to guarantee that it *wouldn't* fail), or in particular to find where cc and c89 differ in their interpretation of such a coercion. In any case, to summarise, there was no problem with c89 when I stopped trying to coerce negative values into unsigned values. Cheers, Tony. -- _____________________________________________________________________________ A.B.Coates, Dept. of Physics, The University of Queensland QLD 4072 Australia. Email: coates@physics.uq.oz.au Phone: (07/+617) 365-3424 Fax: (07/+617) 365-1242 Disclaimer: The University is ignorant of my opinions, let alone guilty ... _____________________________________________________________________________