From: coates@kelvin.physics.uq.oz.au (Tony Coates)
Subject: Re: Switch failure with c89 compiler on Alpha, OSF/1.3
Date: 24 Mar 94 16:44:54 [thread overview]
Message-ID: <COATES.94Mar24164454@kelvin.physics.uq.oz.au> (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 ...
_____________________________________________________________________________
reply other threads:[~1994-03-24 21:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox