Xref: utzoo gnu.gcc.bug:1785 comp.lang.c:24708 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!wuarchive!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: gnu.gcc.bug,comp.lang.c Subject: Re: switch() difficulties in gcc v1.35 Summary: it turns into a goto label Message-ID: <1989Dec23.131341.3322@virtech.uucp> Date: 23 Dec 89 13:13:41 GMT References: <18472@netnews.upenn.edu> Organization: Virtual Technologies Inc. Lines: 20 In article <18472@netnews.upenn.edu>, weisen@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 | +-----------------------------------------------------------------------+