ternary operator not shortcut

Bug #1187729 reported by Thorsten Glaser
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mksh
Fix Released
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…

Revision history for this message
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.