Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8449967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:50:43+00:00 2026-06-10T10:50:43+00:00

While inspecting a non-functioning bit of code, I realized that I’d left the case

  • 0

While inspecting a non-functioning bit of code, I realized that I’d left the “case” out of my switch statements. The buggy code had the following format

switch (foo) {
   firstElem:
       ...
       break;
   secondElem:
       ...
       break;
}

Where firstElem and secondElem are part of an enumerated list. When I step through the code, it jumps from switch to the closing bracket, since it finds no match.

This was simple to fix, but it left me uneasy because XCode did not complain at all either at compile or run-time. Why?

  1. Is there something in the structure of the language that makes a switch case harder to interpret?
  2. Is there ever an instance in which you would want to omit the case statement to produce some other behavior (which I know nothing about)?
  3. Does this happen in other languages? I know Objective-C is a “strict superset of C,” so I assume the same might happen in C (depending on the compiler). What about Java? C++?

UPDATE: I’m using XCode 4.4.1 (although I’ll go and upgrade in a sec). This is part of an established project.**

FURTHER UPDATE AND REFERENCE Kevin Ballard correctly pointed out that I was accidentally defining labels. For more info on labels and GOTO, you can find a discussion in The C Programming Language 3.8 in which Kernighan and Richie conclude that (although they might have some use in error checking)

… code that relies on goto statements is generally harder to understand and to maintain than code without gotos. Although we are not dogmatic about the matter, it does seem that goto statements should be used rarely, if at all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:50:45+00:00Added an answer on June 10, 2026 at 10:50 am

    What you have is a bunch of regular old labels inside your switch. That’s perfectly legal. Xcode isn’t complaining because a switch with no case statements is legal, although a bit strange.

    That said, clang will emit a warning upon seeing a switch statement with no case statements. Are you using GCC?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While i was inspecting facebook html code through with firebug in Chrome, i found
I am inspecting a piece of existing code and found out it behaves differently
While inspecting ArrayList API, I noticed something that looks strange. Indeed, here the the
While inspecting delegates in C# and .NET in general, I noticed some interesting facts:
While inserting rows into SQL Server CE in WP7 I'm getting a SQLCeException that
While debugging and keep pressing F5, if the source code does not exist, eclipse
I have some code that allows users to upload file attachments into a varbinary(max)
While inspecting an element using Chrome's devtools, in the elements tab, the right-hand side
I have a system that requires a unique 6-digit code to represent an object,
While writing an app, I encountered some odd behavior that I wasn't expecting and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.