Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8029467

Widening of booleans causes bad results

    Details

    • Subcomponent:
    • Resolved In Build:
      b122
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        Widening of types allows widening of boolean to int. This causes undesirable results with both ternary operator and return values of functions. Both examples below print "1", when they should print "true":

        print((function (x) { return x ? true : 0 })(true))
        print((function (x) { if(x) { return true } else { return 0 } })(true))

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  attila Attila Szegedi
                  Reporter:
                  attila Attila Szegedi
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: