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

Error on iterator_category = int with GCC 13 #4079

Closed
rbrich opened this issue Jul 19, 2024 · 2 comments
Closed

Error on iterator_category = int with GCC 13 #4079

rbrich opened this issue Jul 19, 2024 · 2 comments

Comments

@rbrich
Copy link
Contributor

rbrich commented Jul 19, 2024

We have some non-trivial code featuring C++ concepts, which eventually fails on

std::fill_n(ctx.out(), indent, '\t');

where ctx is fmt::format_context.

The relevant part of error output:

/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:1093:5: note: candidate function template not viable: no known conversion from 'typename iterator_traits<basic_appender<char>>::iterator_category' (aka 'int') to 'std::output_iterator_tag' for 4th argument
    __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value,
    ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:1105:5: note: candidate function template not viable: no known conversion from 'typename iterator_traits<basic_appender<char>>::iterator_category' (aka 'int') to 'std::input_iterator_tag' for 4th argument
    __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value,
    ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:1117:5: note: candidate function template not viable: no known conversion from 'typename iterator_traits<basic_appender<char>>::iterator_category' (aka 'int') to 'std::random_access_iterator_tag' for 4th argument
    __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value,
    ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:1086:5: note: candidate template ignored: could not match '_Safe_iterator' against 'basic_appender'
    __fill_n_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first,

I may be able to write a minimal reproducer, but the issue seems obvious:

using iterator_category = int;

Changing this to using iterator_category = std::output_iterator_tag; fixed the errors.

@rbrich
Copy link
Contributor Author

rbrich commented Jul 19, 2024

Reproducer: https://godbolt.org/z/T6n3Pv48d

Fails also with other compilers.

@vitaut
Copy link
Contributor

vitaut commented Jul 19, 2024

Fixed in de684ef, thanks for reporting.

@vitaut vitaut closed this as completed Jul 19, 2024
mtremer pushed a commit to ipfire/ipfire-2.x that referenced this issue Aug 15, 2024
- Update from version 11.0.1 to 11.0.2
- Update of rootfile
- Changelog
    11.0.2
	- Fixed compatibility with non-POSIX systems
	  (fmtlib/fmt#4054,
	  fmtlib/fmt#4060).
	- Fixed performance regressions when using `std::back_insert_iterator` with
	  `fmt::format_to` (fmtlib/fmt#4070).
	- Fixed handling of `std::generator` and move-only iterators
	  (fmtlib/fmt#4053,
	  fmtlib/fmt#4057). Thanks @Arghnews.
	- Made `formatter<std::string_view>::parse` work with types convertible to
	  `std::string_view` (fmtlib/fmt#4036,
	  fmtlib/fmt#4055). Thanks @Arghnews.
	- Made `volatile void*` formattable
	  (fmtlib/fmt#4049,
	  fmtlib/fmt#4056). Thanks @Arghnews.
	- Made `Glib::ustring` not be confused with `std::string`
	  (fmtlib/fmt#4052).
	- Made `fmt::context` iterator compatible with STL algorithms that rely on
	  iterator category (fmtlib/fmt#4079).

Signed-off-by: Adolf Belka <[email protected]>
Signed-off-by: Michael Tremer <[email protected]>
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