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 not respecting max size #2013

Closed
TheAnswer opened this issue Nov 12, 2020 · 1 comment
Closed

format_to_n not respecting max size #2013

TheAnswer opened this issue Nov 12, 2020 · 1 comment
Labels

Comments

@TheAnswer
Copy link

TheAnswer commented Nov 12, 2020

#include <iostream>
#include <fmt/format.h>

int main()
{
std::vector<char> test;

const auto insertResult = fmt::format_to_n(std::back_inserter(test), 4, "{}", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");

std::cout << test.size() << " " << insertResult.size << std::endl;

return 0;
}

The above code hangs or if it succeeds, and you use a static sized buffer it will write over the max size corrupting the buffer.

This behaviour started with fmt 7.1.0, versions below that work fine.

Experiencing this issue in MSVC Version 16.7.7 and gcc 8.1

https://godbolt.org/z/eGEM9s

Program returned: 143

Killed - processing time exceeded

Works fine with fmt 7.0.0

https://godbolt.org/z/1MzY4Y

@TheAnswer TheAnswer changed the title broken format_to_n in MSVC Version 16.7.7 not respecting smax ize broken format_to_n in MSVC Version 16.7.7 not respecting max size Nov 12, 2020
@TheAnswer TheAnswer changed the title broken format_to_n in MSVC Version 16.7.7 not respecting max size broken format_to_n not respecting max size Nov 12, 2020
@TheAnswer TheAnswer changed the title broken format_to_n not respecting max size format_to_n not respecting max size Nov 12, 2020
@vitaut
Copy link
Contributor

vitaut commented Nov 12, 2020

Works as expected on master printing:

4 122

Could be related to #1996 which is already fixed.

@vitaut vitaut closed this as completed Nov 12, 2020
@vitaut vitaut added the invalid label Nov 12, 2020
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