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

alignment flag triggers warning: assuming pointer wraparound does not occur #2757

Closed
uohmak4fvpqe opened this issue Feb 11, 2022 · 3 comments

Comments

@uohmak4fvpqe
Copy link

uohmak4fvpqe commented Feb 11, 2022

I noticed that using the alignment flag as in fmt::print(" ... {:<42} ...", "test") annoyingly triggers -Wstrict-overflow (GCC) :

client.cc:29:5:   in 'constexpr' expansion of 'fmt::v8::basic_format_string<char, const std::basic_string_view<char, std::char_traits<char> >&, const std::basic_string_view<char, std::char_traits<char> >&>("connection to {}{:<12}...\0337")'
/home/linuxbrew/.linuxbrew/include/fmt/core.h:3069:40:   in 'constexpr' expansion of 'fmt::v8::detail::parse_format_string<true, char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> > > >(((fmt::v8::basic_format_string<char, const std::basic_string_view<char, std::char_traits<char> >&, const std::basic_string_view<char, std::char_traits<char> >&>*)this)->fmt::v8::basic_format_string<char, const std::basic_string_view<char, std::char_traits<char> >&, const std::basic_string_view<char, std::char_traits<char> >&>::str_, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> > >(fmt::v8::basic_string_view<char>(((const char*)s)), (fmt::v8::detail::error_handler(), fmt::v8::detail::error_handler())))'
/home/linuxbrew/.linuxbrew/include/fmt/core.h:2627:44:   in 'constexpr' expansion of 'fmt::v8::detail::parse_replacement_field<char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> > >&>((p + -1), end, (* & handler))'
/home/linuxbrew/.linuxbrew/include/fmt/core.h:2602:38:   in 'constexpr' expansion of '(& handler)->fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> > >::on_format_specs(adapter.fmt::v8::detail::parse_replacement_field<char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> > >&>(const char*, const char*, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> > >&)::id_adapter::arg_id, (begin + 1), end)'
/home/linuxbrew/.linuxbrew/include/fmt/core.h:2933:51:   in 'constexpr' expansion of '((fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> > >*)this)->fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> > >::parse_funcs_[id](((fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> > >*)this)->fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> > >::context_)'
/home/linuxbrew/.linuxbrew/include/fmt/core.h:2676:17:   in 'constexpr' expansion of 'f.fmt::v8::formatter<fmt::v8::basic_string_view<char>, char, void>::parse<fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler> >((* & ctx))'
/home/linuxbrew/.linuxbrew/include/fmt/core.h:2984:41:   in 'constexpr' expansion of 'fmt::v8::detail::parse_format_specs<char, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler> > >&>(begin, end, checker)'
/home/linuxbrew/.linuxbrew/include/fmt/core.h:2515:22:   in 'constexpr' expansion of 'fmt::v8::detail::parse_align<char, fmt::v8::detail::specs_checker<fmt::v8::detail::dynamic_specs_handler<fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler> > >&>(begin, end, (* & handler))'
../../up/io.hh:111:93: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
@vitaut
Copy link
Contributor

vitaut commented Feb 11, 2022

I was not able to repro it on current master: https://godbolt.org/z/YP6Kfoq38.

@uohmak4fvpqe
Copy link
Author

I was not able to repro it on current master: https://godbolt.org/z/YP6Kfoq38.

It does with -std=c++20

@vitaut
Copy link
Contributor

vitaut commented Feb 13, 2022

Fixed in 8e2e4d4. Thanks for reporting.

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

2 participants