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

format_to_n do not write characters #778

Closed
ck3d opened this issue Jun 10, 2018 · 4 comments
Closed

format_to_n do not write characters #778

ck3d opened this issue Jun 10, 2018 · 4 comments

Comments

@ck3d
Copy link

ck3d commented Jun 10, 2018

std::array<char, 1> field{};
assert(fmt::format_to_n(field.begin(), 1, "{}", 'a').size, 1); // passes
assert(field[0] == 'a'); // failes, field[0] == \0

No problems with format_to.

@vitaut
Copy link
Contributor

vitaut commented Jun 10, 2018

This works on the latest master:

#include "fmt/format.h"
#include <array>

int main() {
  std::array<char, 1> field{};
  fmt::format_to_n(field.begin(), 1, "{}", 'a');
  fmt::print("{}", field[0]); // prints 'a'
}

Not sure if it is related, but your first assert seems invalid (probably should be == instead of ,).

@vitaut vitaut closed this as completed Jun 10, 2018
@wkenyon
Copy link

wkenyon commented Jun 22, 2018

This may work on master, but it is broken in the latest release, 5.0.0.
Perhaps it's worth releasing 5.0.1 with this fixed? It seems like a pretty serious bug.

@vitaut
Copy link
Contributor

vitaut commented Jun 23, 2018

Yes, I plan to release a new minor version soon.

@vitaut
Copy link
Contributor

vitaut commented Jul 8, 2018

Version 5.1.0 which includes this fix among other things has been released: https://github.com/fmtlib/fmt/releases/tag/5.1.0

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

No branches or pull requests

3 participants