Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-89955

IDL validator generation converts integer literals greater than the int32 maximum to floats

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Service Arch
    • ALL

      IDL binds integer literals parsed from validator expressions which are greater than 2^31-1 to floating-point expressions rather than integer expressions, even though C++ literals can be greater than 32 bits. This can result in generating validators that perform comparisons between floating points and integers, which maybe imprecise.

      e.g. the following field

      foo:     
          type: long
          validator: { gte: 2147483647 }
      

      generates the following validator:

      void Ping::validateBlah(IDLParserContext& ctxt, const std::int64_t value)
      {
          if (!(value >= 2147483748.0)) {
              throwComparisonError<std::int64_t>(ctxt, "blah", ">="_sd, value, 2147483748.0);
          }
      }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            patrick.freed@mongodb.com Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: