Switch bug introduced in 1.1.36 Topic is solved

Report problems with documented functionality
User avatar
JoeWinograd
Posts: 2182
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Switch bug introduced in 1.1.36

Post by JoeWinograd » 01 Dec 2022, 13:32

This code works in 1.1.35 and fails in 1.1.36:

Code: Select all

MsgBox % TestSwitch(1) . "`n" . A_AhkVersion
ExitApp
TestSwitch(Num)
{
  Switch Num
  {
    Case 1: Msg:="fails in 1.1.36 - works in 1.1.35"
    Default: Msg:="default"
  }
  Return Msg
}
It seems to be related to the parameter in the function call because this code works in both 1.1.35 and 1.1.36:

Code: Select all

Num:=1
Switch Num
{
  Case 1: Msg:="works in both 1.1.35 and 1.1.36"
  Default: Msg:="default"
}
MsgBox % Msg . "`n" . A_AhkVersion
ExitApp
This issue was also noted here:
viewtopic.php?f=76&t=111063

Regards, Joe

User avatar
RaptorX
Posts: 371
Joined: 06 Dec 2014, 14:27
Contact:

Re: Switch bug introduced in 1.1.36

Post by RaptorX » 01 Dec 2022, 14:59

This code is only failing in the 64bit version of 1.1.36.0

Compare 32bit:
---------------------------
PB2N7.code
---------------------------
fails in 1.1.36 - works in 1.1.35
1.1.36.00 32bit
---------------------------
OK
---------------------------
Vs 64bit:
---------------------------
6KRYz.code
---------------------------
default
1.1.36.00 64bit
---------------------------
OK
---------------------------
This results in incorrect cases being selected during a switch statement like this:
image.png
image.png (30.41 KiB) Viewed 862 times
There is also an invalid memory read/write issue on v1.1.36.0, Ill be posting in a bit.
Edit: here is the post
Projects:
AHK-ToolKit

User avatar
JoeWinograd
Posts: 2182
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Switch bug introduced in 1.1.36

Post by JoeWinograd » 01 Dec 2022, 15:16

RaptorX wrote:This code is only failing in the 64bit version of 1.1.36.0
Good catch! Confirmed here. Thanks, Joe

lexikos
Posts: 9560
Joined: 30 Sep 2013, 04:07
Contact:

Re: Switch bug introduced in 1.1.36  Topic is solved

Post by lexikos » 02 Dec 2022, 04:32

lexikos wrote:
02 Dec 2022, 04:30
v1.1.36.01
Fixed undefined behaviour within Switch when the switch or case expression yields a string or numeric literal which is then compared numerically.
(This exhibited as a Critical Error under some conditions, but the conditions were coincidental.)

User avatar
JoeWinograd
Posts: 2182
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Switch bug introduced in 1.1.36

Post by JoeWinograd » 02 Dec 2022, 10:30

lexikos wrote:v1.1.36.01
Thanks for the fast fix...much appreciated!

Post Reply

Return to “Bug Reports”