ternary operator not shortcut
Bug #1187729 reported by
Thorsten Glaser
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…
Changed in mksh: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Fix committed, will be in R47.
*** Please test! ***