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: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0, 8.0.0-rc14
    • Affects Version/s: None
    • Component/s: None
    • Service Arch
    • Minor Change
    • ALL
    • v8.0
    • Programmability 2024-06-10, Programmability 2024-06-24, Programmability 2024-07-08

      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:
            hriday.sheth@mongodb.com Hriday Sheth (Inactive)
            Reporter:
            patrick.freed@mongodb.com Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: