Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* Re: Switch failure with c89 compiler on Alpha, OSF/1.3
@ 1994-03-24 21:44 Tony Coates
  0 siblings, 0 replies; only message in thread
From: Tony Coates @ 1994-03-24 21:44 UTC (permalink / raw)


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 ...
_____________________________________________________________________________


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1994-03-24 21:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-03-24 21:44 Switch failure with c89 compiler on Alpha, OSF/1.3 Tony Coates

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox