#include <fmt/chrono.h>
#include <fmt/core.h>
int main()
{
auto tic = std::chrono::high_resolution_clock::now();
fmt::print("Hello World!\n");
auto toc = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli>tictoc = toc - tic;
fmt::print("time taken: {}\n", tictoc);
}
/usr/local/bin/g++ -O2 -g -Werror -std=c++23 -march=native -O3 -Wno-error=non-template-friend -Wall -I/usr/src/local/fmt/include -c fmttest.cc
In file included from /usr/src/local/fmt/include/fmt/format.h:49,
from /usr/src/local/fmt/include/fmt/chrono.h:21,
from fmttest.cc:1:
/usr/src/local/fmt/include/fmt/core.h: In instantiation of 'constexpr fmt::v9::detail::value<Context> fmt::v9::detail::make_value(T&&) [with Context = fmt::v9::basic_format_context<fmt::v9::appender, char>; T = std::chrono::duration<double, std::ratio<1, 1000> >&]':
/usr/src/local/fmt/include/fmt/core.h:1704:29: required from 'constexpr fmt::v9::detail::value<Context> fmt::v9::detail::make_arg(T&&) [with bool IS_PACKED = true; Context = fmt::v9::basic_format_context<fmt::v9::appender, char>; type <anonymous> = fmt::v9::detail::type::custom_type; T = std::chrono::duration<double, std::ratio<1, 1000> >&; typename std::enable_if<IS_PACKED, int>::type <anonymous> = 0]'
/usr/src/local/fmt/include/fmt/core.h:1819:77: required from 'constexpr fmt::v9::format_arg_store<Context, Args>::format_arg_store(T&& ...) [with T = {std::chrono::duration<double, std::ratio<1, 1000> >&}; Context = fmt::v9::basic_format_context<fmt::v9::appender, char>; Args = {std::chrono::duration<double, std::ratio<1, 1000> >}]'
/usr/src/local/fmt/include/fmt/core.h:1836:31: required from 'constexpr fmt::v9::format_arg_store<Context, typename std::remove_cv<typename std::remove_reference<_Args>::type>::type ...> fmt::v9::make_format_args(T&& ...) [with Context = basic_format_context<appender, char>; T = {std::chrono::duration<double, std::ratio<1, 1000> >&}]'
/usr/src/local/fmt/include/fmt/core.h:2898:44: required from 'void fmt::v9::print(format_string<T ...>, T&& ...) [with T = {std::chrono::duration<double, std::ratio<1, 1000> >&}; format_string<T ...> = basic_format_string<char, std::chrono::duration<double, std::ratio<1, 1000> >&>]'
fmttest.cc:10:12: required from here
/usr/src/local/fmt/include/fmt/core.h:1667:15: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
1667 | const auto& arg = arg_mapper<Context>().map(FMT_FORWARD(val));
| ^~~
/usr/src/local/fmt/include/fmt/core.h:1667:46: note: the temporary was destroyed at the end of the full expression 'fmt::v9::detail::arg_mapper<fmt::v9::basic_format_context<fmt::v9::appender, char> >().fmt::v9::detail::arg_mapper<fmt::v9::basic_format_context<fmt::v9::appender, char> >::map<std::chrono::duration<double, std::ratio<1, 1000> >&>((* & val))'
1667 | const auto& arg = arg_mapper<Context>().map(FMT_FORWARD(val));
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/c++/13.0.1/algorithm:60,
from /usr/src/local/fmt/include/fmt/chrono.h:11:
In static member function 'static constexpr _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = unsigned int; _Up = unsigned int; bool _IsMove = false]',
inlined from 'constexpr _OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = unsigned int*; _OI = unsigned int*]' at /usr/local/include/c++/13.0.1/bits/stl_algobase.h:506:30,
inlined from 'constexpr _OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = unsigned int*; _OI = unsigned int*]' at /usr/local/include/c++/13.0.1/bits/stl_algobase.h:533:42,
inlined from 'constexpr _OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = unsigned int*; _OI = unsigned int*]' at /usr/local/include/c++/13.0.1/bits/stl_algobase.h:540:31,
inlined from 'constexpr _OI std::copy(_II, _II, _OI) [with _II = unsigned int*; _OI = unsigned int*]' at /usr/local/include/c++/13.0.1/bits/stl_algobase.h:633:7,
inlined from 'static _ForwardIterator std::__uninitialized_copy<true>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = unsigned int*; _ForwardIterator = unsigned int*]' at /usr/local/include/c++/13.0.1/bits/stl_uninitialized.h:147:27,
inlined from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = unsigned int*; _ForwardIterator = unsigned int*]' at /usr/local/include/c++/13.0.1/bits/stl_uninitialized.h:185:15,
inlined from 'constexpr void fmt::v9::basic_memory_buffer<T, SIZE, Allocator>::grow(size_t) [with T = unsigned int; long unsigned int SIZE = 32; Allocator = std::allocator<unsigned int>]' at /usr/src/local/fmt/include/fmt/format.h:951:28,
inlined from 'constexpr void fmt::v9::detail::buffer<T>::try_reserve(size_t) [with T = unsigned int]' at /usr/src/local/fmt/include/fmt/core.h:921:39,
inlined from 'constexpr void fmt::v9::detail::buffer<T>::try_resize(size_t) [with T = unsigned int]' at /usr/src/local/fmt/include/fmt/core.h:912:16,
inlined from 'constexpr void fmt::v9::basic_memory_buffer<T, SIZE, Allocator>::resize(size_t) [with T = unsigned int; long unsigned int SIZE = 32; Allocator = std::allocator<unsigned int>]' at /usr/src/local/fmt/include/fmt/format.h:1022:63,
inlined from 'constexpr void fmt::v9::detail::bigint::assign(UInt) [with UInt = long unsigned int; typename std::enable_if<(std::is_same<UInt, long unsigned int>::value || std::is_same<_Tp, __int128 unsigned>::value), int>::type <anonymous> = 0]' at /usr/src/local/fmt/include/fmt/format.h:3035:19,
inlined from 'constexpr void fmt::v9::detail::bigint::operator=(Int) [with Int = int]' at /usr/src/local/fmt/include/fmt/format.h:3056:11,
inlined from 'constexpr void fmt::v9::detail::bigint::assign_pow10(int)' at /usr/src/local/fmt/include/fmt/format.h:3136:11,
inlined from 'constexpr void fmt::v9::detail::bigint::assign_pow10(int)' at /usr/src/local/fmt/include/fmt/format.h:3127:24:
/usr/local/include/c++/13.0.1/bits/stl_algobase.h:437:30: error: 'void* __builtin_memmove(void*, const void*, long unsigned int)' forming offset 4 is out of the bounds [0, 4] [-Werror=array-bounds=]
437 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
Out of bounds seems worth reporting even though it is just a warning...
This is with fmt checkout 75f3b1c
Trivial code:
gcc checkout 101380a8394c22a7a2ea70de2060ee93716156e2 complains with
(assuming the problem isn't with platform dependent memmove)