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

Undefined behaviour in jkqtp_format #43

Closed
Makis42 opened this issue Jun 9, 2020 · 1 comment
Closed

Undefined behaviour in jkqtp_format #43

Makis42 opened this issue Jun 9, 2020 · 1 comment
Assignees
Labels

Comments

@Makis42
Copy link

Makis42 commented Jun 9, 2020

The utility function 'std::string jkqtp_format(const std::string& templ, ...)' uses a reference 'templ' which doesn't work at all with va_start. Every call gets a different result.

My environment: Windows 10, VS2017

jkriege2 added a commit that referenced this issue Jun 27, 2020
…rt was called with a ref-parameter, which does not work. Now there are 4 overloaded template variants. See #43
@jkriege2
Copy link
Owner

Hi!

thanks for reporting ... and sorry for the long wait ...

I didn't know that ... since there is no solution in C++11 that I know of (short of having the format-string as copy-by-value), I fixed this (b22b4ca) by adding 4 overloaded template-functions ... now it works for 1-4 arguments, which is enough for the purpose of the library ...

In general, there is a better solution in C++17 with argument packs (I think) ... but I don't want to enforce C++17 for this lib.

Best,
JAN

@jkriege2 jkriege2 self-assigned this Jun 27, 2020
@jkriege2 jkriege2 added the bug label Jun 27, 2020
jkriege2 added a commit that referenced this issue Jun 28, 2020
…rt was called with a ref-parameter, which does not work. Now there are 4 overloaded template variants. See #43

(cherry picked from commit b22b4ca)
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