Menu

#3 fix invalid formats

None
accepted
nobody
None
5
2014-09-06
2014-09-05
No

There is one format string that is "invalid" in the ocamlnet sources.

In general, invalid formats are nonsensical format strings that were accepted in OCaml 4.01.0 and earlier, but whose semantics is unspecified. They are still accepted by the new Printf implementation of OCaml 4.02.0 but in some cases with different semantics, and they will be statically rejected by OCaml 4.03.0.

You can check for them in OCaml 4.02.0 with the flag -strict-formats.

In the case of ocamlnet, I think the behavior has not changed between 4.01.0 and 4.02.0. The only invalid format is "%0.f". This is considered invalid beause it specifies a padding character (with the flag 0), but no minimum field width (no number before the dot) so there will never be padding. It is also invalid because the dot is not followed by a number. Even though the behaviour has not changed, you should take the opportunity to review the code and fix the format. The patch changes it to "%.0f", which keeps the behaviour unchanged, but that might still be wrong.

1 Attachments

Discussion

  • Gerd Stolpmann

    Gerd Stolpmann - 2014-09-06

    Thanks, I've added the patch. My guess is that $0.f was a typo anyway, and %.0f was meant.

     
  • Gerd Stolpmann

    Gerd Stolpmann - 2014-09-06
    • status: open --> accepted
    • Group: -->
     

Log in to post a comment.