1. Possible switch/case bug
- Posted by wynco Jun 14, 2012
- 1213 views
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()
2. Re: Possible switch/case bug
- Posted by mattlewis (admin) Jun 14, 2012
- 1166 views
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
3. Re: Possible switch/case bug
- Posted by wynco Jun 14, 2012
- 1163 views
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