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

closure interpreted as string when using %_ in printf routine #4756

Closed
vicuna opened this issue Mar 26, 2009 · 2 comments
Closed

closure interpreted as string when using %_ in printf routine #4756

vicuna opened this issue Mar 26, 2009 · 2 comments
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Mar 26, 2009

Original bug ID: 4756
Reporter: rose
Assigned to: @pierreweis
Status: closed (set by @pierreweis on 2009-03-30T10:44:17Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.10.2
Fixed in version: 3.11.1+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

The use of "%_s" e.g. in format specifiers for printf routines is probably not allowed, but the routine cannot check this, because the arguments are counted incorrectly by ocaml. If I write in ocaml the phrase

Printf.sprintf "Hello %s, how %_s you" "Tom";;

the answer is not "Exception ... bad conversion %_ ...", instead a closure is
incorrectly returned as string value:

val s : string = "\212\168\198 ... \000\000"

A detailed description is attached as file 'printf_bug.ml' and a possible
fix (the responsible function) is described there. This is a minor bug, because
it occurs only, if users compile programs with incorrect format specifications.

File attachments

@vicuna
Copy link
Author

vicuna commented Mar 28, 2009

Comment author: @pierreweis

Thank you very much for the detailed bug report. I'm investigating the problem and will let you know the solution I will find.

@vicuna
Copy link
Author

vicuna commented Mar 30, 2009

Comment author: @pierreweis

I fixed it the simple way: %_s conversion now raises an exception in printf.

@vicuna vicuna closed this as completed Mar 30, 2009
@vicuna vicuna added the bug label Mar 20, 2019
dra27 pushed a commit to dra27/ocaml that referenced this issue Feb 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants