Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printf: precision qualifiers sometime result in assert failure #6431

Closed
vicuna opened this issue May 18, 2014 · 2 comments
Closed

Printf: precision qualifiers sometime result in assert failure #6431

vicuna opened this issue May 18, 2014 · 2 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented May 18, 2014

Original bug ID: 6431
Reporter: @gasche
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2015-12-11T18:27:54Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.0+dev
Target version: 4.02.0+dev
Category: standard library
Duplicate of: #6447

Bug description

The %.3 handling of int conversions (fix_int_precision) is not robust enough.

  1. Some case fail with assert failure:

Printf.printf "%.3x" (16*16-1);;

  1. Some case show a slight deviation of behavior wrt. legacy implementation (if we fix (1) above we may as well fix that)

     OCaml version 4.02.0+dev6-2014-05-12
    

Printf.printf "%#.6x" (16*16-1);;

0x00ff- : unit = ()

    OCaml version 4.01.0

Printf.printf "%#.6x" (16*16-1);;

0x0000ff- : unit = ()

Additional information

Spotted by 'Anarchos' by compiling coq-trunk.

Note that it would be helpful to make the few "assert false" in the runtime code for printf/format/scanf more descriptive (print a decent error message with the problematic format) so that users that would find on a bug of the implementation send helpful bugreports.

File attachments

@vicuna
Copy link
Author

vicuna commented Jun 4, 2014

Comment author: bvaugon

Equivalent to bug report #6447.

Fixed by the attached patch.

@vicuna
Copy link
Author

vicuna commented Jun 4, 2014

Comment author: @gasche

Merged in trunk and 4.02. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants