public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/115099] New: compilation error: format thread::id
@ 2024-05-15  4:16 faithandbrave at gmail dot com
  2024-05-16 11:58 ` [Bug libstdc++/115099] " de34 at live dot cn
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: faithandbrave at gmail dot com @ 2024-05-15  4:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115099

            Bug ID: 115099
           Summary: compilation error: format thread::id
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: faithandbrave at gmail dot com
  Target Milestone: ---

#include <iostream>
#include <format>
#include <thread>

int main()
{
    std::cout << __cpp_lib_formatters << std::endl;
    std::cout << std::format("{}", std::this_thread::get_id()) << std::endl;
    std::cout << std::format("{: >30}", std::this_thread::get_id()) <<
std::endl;
}

outputs:

In file included from prog.cc:3:
/opt/wandbox/gcc-head/include/c++/15.0.0/thread: In instantiation of 'typename
std::basic_format_context<_Out, _CharT>::iterator
std::formatter<std::thread::id, _CharT>::format(std::thread::id,
std::basic_format_context<_Out, _CharT>&) const [with _Out =
std::__format::_Sink_iter<char>; _CharT = char; typename
std::basic_format_context<_Out, _CharT>::iterator =
std::basic_format_context<std::__format::_Sink_iter<char>, char>::iterator]':
/opt/wandbox/gcc-head/include/c++/15.0.0/format:3247:40:   required from
'static void
std::basic_format_arg<_Context>::handle::_S_format(std::basic_format_parse_context<typename
_Context::char_type>&, _Context&, const void*) [with _Tq = const
std::thread::id; _Context =
std::basic_format_context<std::__format::_Sink_iter<char>, char>; typename
_Context::char_type = char]'
 3247 |             __format_ctx.advance_to(__f.format(__val, __format_ctx));
      |                                     ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/15.0.0/format:3255:11:   required from
'std::basic_format_arg<_Context>::handle::handle(_Tp&) [with _Tp =
std::thread::id; _Context =
std::basic_format_context<std::__format::_Sink_iter<char>, char>]'
 3255 |             auto __func = _S_format<__maybe_const_t<_Tp>>;
      |                  ^~~~~~
/opt/wandbox/gcc-head/include/c++/15.0.0/format:3486:13:   required from
'std::basic_format_arg<_Context>::basic_format_arg(_Tp&) [with _Tp =
std::thread::id; _Context =
std::basic_format_context<std::__format::_Sink_iter<char>, char>]'
 3486 |             _M_set(static_cast<_Td>(__v));
      |                    ^~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/15.0.0/format:3743:31:   required from
'static std::__format::_Arg_store<_Context, _Args>::_Element_t
std::__format::_Arg_store<_Context, _Args>::_S_make_elt(_Tp&) [with _Tp =
std::thread::id; _Context =
std::basic_format_context<std::__format::_Sink_iter<char>, char>; _Args =
{std::basic_format_arg<std::basic_format_context<std::__format::_Sink_iter<char>,
char> >::handle}; _Element_t =
std::__format::_Arg_store<std::basic_format_context<std::__format::_Sink_iter<char>,
char>,
std::basic_format_arg<std::basic_format_context<std::__format::_Sink_iter<char>,
char> >::handle>::_Element_t]'
 3743 |           basic_format_arg<_Context> __arg(__v);
      |                                      ^~~~~
/opt/wandbox/gcc-head/include/c++/15.0.0/format:3754:23:   required from
'std::__format::_Arg_store<_Context, _Args>::_Arg_store(_Tp& ...) [with _Tp =
{std::thread::id}; _Context =
std::basic_format_context<std::__format::_Sink_iter<char>, char>; _Args =
{std::basic_format_arg<std::basic_format_context<std::__format::_Sink_iter<char>,
char> >::handle}]'
 3754 |         : _M_args{_S_make_elt(__a)...}
      |                   ~~~~~~~~~~~^~~~~
/opt/wandbox/gcc-head/include/c++/15.0.0/format:3804:14:   required from 'auto
std::make_format_args(_Args& ...) [with _Context =
basic_format_context<__format::_Sink_iter<char>, char>; _Args = {thread::id}]'
 3804 |       return _Store(__fmt_args...);
      |              ^~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/15.0.0/format:4291:61:   required from
'std::string std::format(format_string<_Args ...>, _Args&& ...) [with _Args =
{thread::id}; string = __cxx11::basic_string<char>; format_string<_Args ...> =
basic_format_string<char, thread::id>]'
 4291 |     { return std::vformat(__fmt.get(),
std::make_format_args(__args...)); }
      |                                        ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
prog.cc:8:29:   required from here
    8 |     std::cout << std::format("{}", std::this_thread::get_id()) <<
std::endl;
      |                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/15.0.0/thread:334:44: error:
'std::__cxx11::basic_ostringstream<char> __os' has incomplete type
  334 |           std::basic_ostringstream<_CharT> __os;
      |                                            ^~~~


It seems missing include <sstream> at <thread>.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-22 11:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-15  4:16 [Bug libstdc++/115099] New: compilation error: format thread::id faithandbrave at gmail dot com
2024-05-16 11:58 ` [Bug libstdc++/115099] " de34 at live dot cn
2024-05-17 11:50 ` redi at gcc dot gnu.org
2024-05-22  9:05 ` cvs-commit at gcc dot gnu.org
2024-05-22 11:44 ` cvs-commit at gcc dot gnu.org
2024-05-22 11:45 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).