473,671 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error: jump to case label

Hello,

Does anyone know what the following g++ compiler error message means:

error: jump to case label

I get this error when switching two case labels together with their bodies.
I have no setjmp/longjmp or gotos in my program.

Thanks,

Neil
Jul 22 '05 #1
11 17305
Neil Zanella wrote:
I get this error when switching two case labels together with their bodies.


Explain that further or better yet post the offending code.
Jul 22 '05 #2
On Fri, 02 Apr 2004 15:09:00 -0800, Neil Zanella wrote:
Hello,

Does anyone know what the following g++ compiler error message means:

error: jump to case label

I get this error when switching two case labels together with their bodies.
I have no setjmp/longjmp or gotos in my program.


Perhaps the problem is "jump to case label croses initialization" ?

The following is not allowed:

switch (a)
{
case 1:
int a = 6;
//stuff
break;

case 2:
//stuff
break;
}

The following is allowed:

switch (a)
{
case 1:
{
int a = 6;
//stuff
}
break;

case 2:
//stuff
break;
}

James

Jul 22 '05 #3
On Fri, 02 Apr 2004 15:09:00 -0800, Neil Zanella wrote:
Hello,

Does anyone know what the following g++ compiler error message means:

error: jump to case label

I get this error when switching two case labels together with their bodies.
I have no setjmp/longjmp or gotos in my program.


Perhaps the problem is "jump to case label croses initialization" ?

The following is not allowed:

switch (a)
{
case 1:
int a = 6;
//stuff
break;

case 2:
//stuff
break;
}

The following is allowed:

switch (a)
{
case 1:
{
int a = 6;
//stuff
}
break;

case 2:
//stuff
break;
}

James

Jul 22 '05 #4
Bill Seurer <se****@us.ibm. com> wrote in message news:<c4******* ****@news.rchla nd.ibm.com>...
Neil Zanella wrote:
I get this error when switching two case labels together with their bodies.


Explain that further or better yet post the offending code.


Sure I will. Here is the code. Uncommenting the lines for case 1 produces
the compiler error message. Furthermore, out of curiosity, as an unrelated
matter, I am quite interested in knowing how come the program starts looping
when some large number is entered.

Thanks,

Neil

#include <iostream>

int main() {
unsigned int x; do {
std::cout << "Please enter an integer: " << std::flush;
std::cin >> x;
switch (x) {
case 0:
std::cout << "Hello!" << std::endl;
break;
default:
unsigned int y = ++x;
std::cout << "You could have entered " << y;
std::cout << ". Why didn't you?" << std::endl;
break;
//case 1:
// std::cout << "What??? You entered one?" << std::endl;
// break;
}
} while (x != 0);
}
Jul 22 '05 #5
Bill Seurer <se****@us.ibm. com> wrote in message news:<c4******* ****@news.rchla nd.ibm.com>...
Neil Zanella wrote:
I get this error when switching two case labels together with their bodies.


Explain that further or better yet post the offending code.


Sure I will. Here is the code. Uncommenting the lines for case 1 produces
the compiler error message. Furthermore, out of curiosity, as an unrelated
matter, I am quite interested in knowing how come the program starts looping
when some large number is entered.

Thanks,

Neil

#include <iostream>

int main() {
unsigned int x; do {
std::cout << "Please enter an integer: " << std::flush;
std::cin >> x;
switch (x) {
case 0:
std::cout << "Hello!" << std::endl;
break;
default:
unsigned int y = ++x;
std::cout << "You could have entered " << y;
std::cout << ". Why didn't you?" << std::endl;
break;
//case 1:
// std::cout << "What??? You entered one?" << std::endl;
// break;
}
} while (x != 0);
}
Jul 22 '05 #6
Neil Zanella wrote:
Sure I will. Here is the code. Uncommenting the lines for case 1 produces
the compiler error message.
Try moving them before the 'default'
Furthermore, out of curiosity, as an unrelated
matter, I am quite interested in knowing how come the program starts looping
when some large number is entered.
cin.fail() is set and all subsequent ">>" operations are ignored,
with x unmodified every time. Hence, if x happened to be non-zero,
the loop iterates infinitely.

Thanks,

Neil

#include <iostream>

int main() {
unsigned int x; do {
std::cout << "Please enter an integer: " << std::flush;
std::cin >> x;
switch (x) {
case 0:
std::cout << "Hello!" << std::endl;
break;
default:
unsigned int y = ++x;
std::cout << "You could have entered " << y;
std::cout << ". Why didn't you?" << std::endl;
break;
//case 1:
// std::cout << "What??? You entered one?" << std::endl;
// break;
}
} while (x != 0);
}


HTH,
- J.
Jul 22 '05 #7
Neil Zanella wrote:
Sure I will. Here is the code. Uncommenting the lines for case 1 produces
the compiler error message.
Try moving them before the 'default'
Furthermore, out of curiosity, as an unrelated
matter, I am quite interested in knowing how come the program starts looping
when some large number is entered.
cin.fail() is set and all subsequent ">>" operations are ignored,
with x unmodified every time. Hence, if x happened to be non-zero,
the loop iterates infinitely.

Thanks,

Neil

#include <iostream>

int main() {
unsigned int x; do {
std::cout << "Please enter an integer: " << std::flush;
std::cin >> x;
switch (x) {
case 0:
std::cout << "Hello!" << std::endl;
break;
default:
unsigned int y = ++x;
std::cout << "You could have entered " << y;
std::cout << ". Why didn't you?" << std::endl;
break;
//case 1:
// std::cout << "What??? You entered one?" << std::endl;
// break;
}
} while (x != 0);
}


HTH,
- J.
Jul 22 '05 #8
Jacek Dziedzic <ja************ *@janowo.net> wrote in message:
Try moving them before the 'default'


Thank you for your reply...
I know that works but that doens't really explain the nature of the problem.

Regards,

Neil
#include <iostream>

int main() {
unsigned int x; do {
std::cout << "Please enter an integer: " << std::flush;
std::cin >> x;
switch (x) {
case 0:
std::cout << "Hello!" << std::endl;
break;
default:
unsigned int y = ++x;
std::cout << "You could have entered " << y;
std::cout << ". Why didn't you?" << std::endl;
break;
//case 1:
// std::cout << "What??? You entered one?" << std::endl;
// break;
}
} while (x != 0);
}


HTH,
- J.

Jul 22 '05 #9
Jacek Dziedzic <ja************ *@janowo.net> wrote in message:
Try moving them before the 'default'


Thank you for your reply...
I know that works but that doens't really explain the nature of the problem.

Regards,

Neil
#include <iostream>

int main() {
unsigned int x; do {
std::cout << "Please enter an integer: " << std::flush;
std::cin >> x;
switch (x) {
case 0:
std::cout << "Hello!" << std::endl;
break;
default:
unsigned int y = ++x;
std::cout << "You could have entered " << y;
std::cout << ". Why didn't you?" << std::endl;
break;
//case 1:
// std::cout << "What??? You entered one?" << std::endl;
// break;
}
} while (x != 0);
}


HTH,
- J.

Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3843
by: Andreas | last post by:
Hi, can someone tell me how i do create a jump table in c or c++ ? I tried this: void f() { void *jump_table = { label1,
10
360
by: Neil Zanella | last post by:
Hello, Does anyone know what the following g++ compiler error message means: error: jump to case label I get this error when switching two case labels together with their bodies. I have no setjmp/longjmp or gotos in my program. Thanks,
11
2686
by: Steve Hoyer | last post by:
I am trying to deploy my first asp.net app to our webserver (2K server, IIS 5) My start page comes up and you can get to the subsequent pages that are tied into our sql server (2K). Each page has a datagrid that loads up just fine, but when I click on any link that updates the page, i.e. a column header to sort the database, it returns a 404 error. Any ideas why it works the for the inital load and not on a postback?
33
3143
by: Anthony England | last post by:
I am considering general error handling routines and have written a sample function to look up an ID in a table. The function returns True if it can find the ID and create a recordset based on that ID, otherwise it returns false. **I am not looking for comments on the usefulness of this function - it is only to demonstrate error handling** There are three versions of this code. David Fenton says under the earlier thread "DAO...
2
1875
by: dc15 | last post by:
I am trying to write an application, taking input from various text boxes and appending it to a text file.... it was working, then I had to create various sub procedures to reflect limits set in place (class: A through C), (type: X, I, S), grade (4 through 6) Ive tried everything and it still wont work, anyone have any ideas? heres my code Public Class Form1
9
10997
by: sam_cit | last post by:
Hi Everyone, I wanted to know as to how a switch case like the following one is converted into a jump table by the compiler, assuming that it does, switch(i) { case 4 : { ... printf("4");
3
1537
by: AJ32 | last post by:
I have written a Dev-C++ program that needs to read and write to and from files, also it needs to use the goto function to jump to different parts of the program, after I finished writting the program there were 2 problems I cannot fix the first error comes when I write something like this: if (input = 'N') { goto Next; } ofstream file(file.txt, ios::app); Next: ...
12
5666
by: Franz Hose | last post by:
the following program, when compiled with gcc and '-std=c99', gcc says test.c:6: error: jump into scope of identifier with variably modified type that is, it does not even compile. lcc-win32, on the other hand, reports Warning test.c: 7 unreachable code
1
2569
by: KRISHNA PRAVI | last post by:
the error is "runtime error object expected" here is the code....................................................................................... <script language="javascript" src="../Scripts/calender.js"></script> </HEAD> <body bgColor="white" MS_POSITIONING="GridLayout"> <form id="Form1" style="LEFT: 0px; POSITION: absolute; TOP: 0px" method="post" runat="server"> <!--<table width="100%" style="LEFT: 0px; POSITION:...
0
8483
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8603
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7444
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5703
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.