switch() difficulties in gcc v1.35

Conor P. Cahill cpcahil at virtech.uucp
Sun Dec 24 00:13:41 AEST 1989


In article <18472 at netnews.upenn.edu>, weisen at eniac.seas.upenn.edu) (Neil I. Weisenfeld ;-) writes:
> I am using gcc v1.35 under DEC's ULTRIX.  I was diligently working on
> a project that was due the next morning when quite a bit of my time
> was taken up trying to find a really weird bug.  As it turns out, I
> misspelled `default' as `defualt' in a switch statement.  The code
> compiled without an error, however the `defualt' was never executed;
> it just dropped out of the switch.  Is this a bug or is there a
> rational `C' explanation for this?

This will happen in any C compiler.  Since the defualt does not 
match "default" it is then interpreted as a label (used by goto's).  So
your defualt: code would be executed as part of the preceding case.

If you had linted the code, you would have gotten a message about
defualt being unused.  This would have pointed out the problem to you.
-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.lang.c mailing list