1. Possible switch/case bug

The following code 'works' when interpreted, but generates a duplicate case value error if compiled with gcc.
It should generates a duplicate case value error when interpreted, or am I missing something.
I also noticed that the last 'case' will trigger, regardless which 'case' comes first. Should it not trigger the first case?

include std/console.e 
 
constant min = 1 
constant max = 1 
 
integer test = min 
 
switch test do 
	case min then 
		printf(1,"Min = %d",min) 
	case max then 
		printf(1,"Max = %d",max) 
end switch 
 
wait_key() 
new topic     » topic index » view message » categorize

2. Re: Possible switch/case bug

wynco said...

The following code 'works' when interpreted, but generates a duplicate case value error if compiled with gcc.
It should generates a duplicate case value error when interpreted, or am I missing something.
I also noticed that the last 'case' will trigger, regardless which 'case' comes first. Should it not trigger the first case?

Yes, this is a bug, recently fixed. See ticket:744. In 4.1, this will be an interpreter error, too. Basically, your code is telling euphoria to do two contradictory things. We were checking for duplicate symbols, but not duplicate values.

Matt

new topic     » goto parent     » topic index » view message » categorize

3. Re: Possible switch/case bug

mattlewis said...
wynco said...

The following code 'works' when interpreted, but generates a duplicate case value error if compiled with gcc.
It should generates a duplicate case value error when interpreted, or am I missing something.
I also noticed that the last 'case' will trigger, regardless which 'case' comes first. Should it not trigger the first case?

Yes, this is a bug, recently fixed. See ticket:744. In 4.1, this will be an interpreter error, too. Basically, your code is telling euphoria to do two contradictory things. We were checking for duplicate symbols, but not duplicate values.

Matt

Excellent. I found it when I had a logic error in my program that was passing the interpreter fine but when compiled it was showing up. It would have caused the interpreted version of my program to display an incorrect error message to the user at some point. Must be time to upgrade from 4.0.3 to 4.1

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu