* DEC AXP (Alpha) c89 bug
@ 1994-03-17 16:16 Tony Coates
1994-03-17 11:37 ` Charles M Richmond
1994-03-17 22:45 ` Holger Rasch
0 siblings, 2 replies; 5+ messages in thread
From: Tony Coates @ 1994-03-17 16:16 UTC (permalink / raw)
We just received the DEC AXP (Alpha) c89 compiler as part of DEC's cxx
C++ compiler package. We are running OSF/1.3. I tried recompiling an
old program which compiled under cc and ran correctly. However, after
compilation with c89, the program failed. Debugging with dbx, and
with the aid of a few printf statements which I had to add, I found
that, when compiled with c89, a switch statement of the form
switch(<function evaluation>) {
case -1: <blah>; break;
case 1: <blah>; break;
default: <blah>
}
was reaching the default statement, even though the function
evaluation yielded -1. The same statement selected the -1 case when
compiled with cc.
As such, I would recommend cc over c89 if possible, in spite
of the fact that the pre-processor for cc is not proper ANSI (can't
leave spaces in from of #line directives, for example).
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] 5+ messages in thread* Re: DEC AXP (Alpha) c89 bug 1994-03-17 16:16 DEC AXP (Alpha) c89 bug Tony Coates @ 1994-03-17 11:37 ` Charles M Richmond 1994-03-18 16:14 ` Tony Coates 1994-03-17 22:45 ` Holger Rasch 1 sibling, 1 reply; 5+ messages in thread From: Charles M Richmond @ 1994-03-17 11:37 UTC (permalink / raw) coates@kelvin.physics.uq.oz.au (Tony Coates) writes: >We just received the DEC AXP (Alpha) c89 compiler as part of DEC's cxx >C++ compiler package. We are running OSF/1.3. I tried recompiling an >old program which compiled under cc and ran correctly. However, after >compilation with c89, the program failed. Debugging with dbx, and >with the aid of a few printf statements which I had to add, I found >that, when compiled with c89, a switch statement of the form > switch(<function evaluation>) { > case -1: <blah>; break; > case 1: <blah>; break; > default: <blah> > } >was reaching the default statement, even though the function >evaluation yielded -1. The same statement selected the -1 case when >compiled with cc. > As such, I would recommend cc over c89 if possible, in spite >of the fact that the pre-processor for cc is not proper ANSI (can't >leave spaces in from of #line directives, for example). > Cheers, > Tony. >-- If you would provide us with an "actual" failing case (bad pun) then the net might be able to help. I would guess that your function evaluation and your case data use different types. Personally, I like c89. Charlie -- ***************************************************************************** * Charles Richmond Integrated International Systems Corporation * * cmr@asoko.iisc.com cmr@world.std.com * * Specializing in UNIX, X, Image Processing, and Communications. * ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: DEC AXP (Alpha) c89 bug 1994-03-17 11:37 ` Charles M Richmond @ 1994-03-18 16:14 ` Tony Coates 0 siblings, 0 replies; 5+ messages in thread From: Tony Coates @ 1994-03-18 16:14 UTC (permalink / raw) In article <CMt4B2.CBr@world.std.com> cmr@world.std.com (Charles M Richmond) writes: coates@kelvin.physics.uq.oz.au (Tony Coates) (*me*) writes: >We just received the DEC AXP (Alpha) c89 compiler as part of DEC's cxx >C++ compiler package. We are running OSF/1.3. I tried recompiling an >old program which compiled under cc and ran correctly. However, after >compilation with c89, the program failed. Debugging with dbx, and >with the aid of a few printf statements which I had to add, I found >that, when compiled with c89, a switch statement of the form > switch(<function evaluation>) { > case -1: <blah>; break; > case 1: <blah>; break; > default: <blah> > } >was reaching the default statement, even though the function >evaluation yielded -1. The same statement selected the -1 case when >compiled with cc. If you would provide us with an "actual" failing case (bad pun) then the net might be able to help. I would guess that your function evaluation and your case data use different types. Personally, I like c89. Well, I didn't provide the actual case, because I thought it too long, but I will now. The function returns a `signof' value - if this isn't an integer, then I'll be amused. The evalutaion is a bit compicated, but runs as follows. The switch that fails looks like switch(key_compare(p_tbky,p_tb->ca_p_parent->p_key)) { case -1: p_tb->ca_p_parent->p_left =p_new; break; case 1: p_tb->ca_p_parent->p_right=p_new; break; default: as_bomb("tb_ins: Key comparison function is inconsistent."); } and runs through to the default case when the function returns -1 (only under c89, not under cc. It works under cc). keycompare is a macro, defined as follows: #define key_compare(a,b) ((*(p_tb->p_kycm))((a),(b))) The particular function `p_kycm' which is called in the failing case is the following: LOCAL sign cm_name P_((name_t *,name_t *)); LOCAL sign cm_name(name1,name2) /* Compares two names and returns: */ /* -1 if name1 < name2 */ /* 0 if name1 = name2 */ /* 1 if name1 > name2 */ /* Provides a full ordering on the set of names. */ name_t *name1; name_t *name2; { return signof(strcmp(&(*name1)[0],&(*name2)[0])); } where the P_ macro just serves here to create an ANSI prototype, and the name_t structure is a fixed length array of characters. As I noted, this fails when compiled under c89, not cc, on a DEC AXP running OSF/1.3. I haven't attempted to try to convert this to a trivial example to check under what conditions it can occur, because changing back from c89 to cc is less effort for me than trying to create an example where it fails. Given that switch statements usually work, I can only hypothesise that this is a bug which doesn't arise in simple test programs, only in larger programs. 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] 5+ messages in thread
* Re: DEC AXP (Alpha) c89 bug 1994-03-17 16:16 DEC AXP (Alpha) c89 bug Tony Coates 1994-03-17 11:37 ` Charles M Richmond @ 1994-03-17 22:45 ` Holger Rasch 1994-03-22 16:27 ` Andre Beck 1 sibling, 1 reply; 5+ messages in thread From: Holger Rasch @ 1994-03-17 22:45 UTC (permalink / raw) coates@kelvin.physics.uq.oz.au (Tony Coates) writes: > [...] I found >that, when compiled with c89, a switch statement of the form > > switch(<function evaluation>) { > case -1: <blah>; break; > case 1: <blah>; break; > default: <blah> > } > >was reaching the default statement, even though the function >evaluation yielded -1. The same statement selected the -1 case when >compiled with cc. hmm ... I wasn't able to reproduce that one but found another interesting thing: /* c89 -DL1 -DL2 -DBIGNUM=<something large> */ main (int ac, char **av) { switch (ac) { #ifdef L1 case -1: break; #endif #ifdef L2 case 1: break; #endif #ifdef BIGNUM case BIGNUM: break; #endif } } /* end */ If you use cc or leave out one of { -DL1 -DL2 -DBIGNUM=... } everything works fine. But please try 'c89 -DL1 -DL2 -DBIGNUM=<xxx>' and use <xxx> = 10000 50000 100000 1000000 ... watch the size of the executable and time and VM used bye the stages of c89. Please tell me there is an option to c89 to disable this feature :-) -- HR ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: DEC AXP (Alpha) c89 bug 1994-03-17 22:45 ` Holger Rasch @ 1994-03-22 16:27 ` Andre Beck 0 siblings, 0 replies; 5+ messages in thread From: Andre Beck @ 1994-03-22 16:27 UTC (permalink / raw) In article <1994Mar17.230228.572@arbi.Informatik.Uni-Oldenburg.DE>, Holger.Rasch@arbi.informatik.uni-oldenburg.de (Holger Rasch) writes: |> |> |>If you use cc or leave out one of { -DL1 -DL2 -DBIGNUM=... } everything |>works fine. |>But please try 'c89 -DL1 -DL2 -DBIGNUM=<xxx>' and use |> <xxx> = 10000 |> 50000 |> 100000 |> 1000000 ... |> |>watch the size of the executable and time and VM used bye the stages of c89. |> |>Please tell me there is an option to c89 to disable this feature :-) |> I thought the alpha is a RISC - I've seen the above behavior by a VAX compiler (M2) which turned CASE statements into CASEx VAX MCs... Or is there a CASE emulation in the PALcode ? -- +-o-+--------------------------------------------------------+-o-+ | o | \\\- Brain Inside -/// | o | | o | ^^^^^^^^^^^^^^ | o | | o | Andre' Beck (ABPSoft) Andre_Beck@IRS.Inf.TU-Dresden.de | o | +-o-+--------------------------------------------------------+-o-+ ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1994-03-22 16:27 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 1994-03-17 16:16 DEC AXP (Alpha) c89 bug Tony Coates 1994-03-17 11:37 ` Charles M Richmond 1994-03-18 16:14 ` Tony Coates 1994-03-17 22:45 ` Holger Rasch 1994-03-22 16:27 ` Andre Beck
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox