GothenburgBitFactory / GothenburgBitFactory/libshared

format.h doesn't handle `char*` correctly

Open
#32 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
7
Forks
30
Avg merge
13h 17m
Merged PRs (30d)
1

Description

```
char *foobar = "lorem ipsum";
format("dolor sit {1} amet", foobar);
```

Expected result:
`"dolor sit lorem ipsum amet"`

Actual result:
`"dolor sit dolor sit amet amet"`

When passing in a `char*`-type variable to `format`'s varargs list, need to cast the variable to `std::string` or convert it to a `std::string`. Not doing so results in `fmt` variable (first arg) being read a second time as one of the vararg variables.

Not a major issue but this small wart can take people by surprise - if this is wontfix, may I recommend adding a comment in the source?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.