ternary operator not shortcut

Reported by Thorsten Glaser on 2013-06-05
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mksh
Low
Unassigned

Bug Description

12:43⎜«ormaaj:#ksh» m# ((m = n = 0, 1?n++:m++?2:3)); print "($n, $m)"
12:43⎜«shbot:#ksh» ormaaj: (1, 1)
12:44⎜«ormaaj:#ksh» $ gcc -x c -std=gnu11 -ggdb -pipe -include stdio.h -o ternarytest - <<<'int main()
     ⎜ { int n, m = n = 0; 1?n++:m++?2:3; printf("(%d, %d)\n", n, m); return 0; }' && ./ternarytest
12:44⎜«ormaaj:#ksh» (1, 0)

Also:

tglase@tglase:~ $ m=0; print $(( 0 ? ++m : 2 )); print $m
2
0
tglase@tglase:~ $ m=0; print $(( 0 ? m++ : 2 )); print $m
2
1

WTF? And I think that worked once. Maybe some of the recent changes…

Thorsten Glaser (mirabilos) wrote :

Fix committed, will be in R47.

*** Please test! ***

Changed in mksh:
importance: Undecided → Low
status: New → Fix Committed
Changed in mksh:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers