* eliminate one case where basic_print_context would copy a string into a fmt::basic_memory_buffer character by character instead of using fmt::basic_memory_buffer::append
* use detail::write instead of re-implementing it
* use to_unsigned to avoid signedness conversion warnings
Problem:
- On Apple clang version 11.0.3 (clang-1103.0.32.62) in C++17 and C++20
mode, clang 11.0.0 in C++17 and C++20 mode, and clang 9.0.1 in C++17
mode, the following error is generated:
In file included from test/compile-test.cc:16:
include/fmt/compile.h:518:25: error: implicit conversion changes signedness: 'long' to 'unsigned long' [-Werror,-Wsign-conversion]
return {f, pos + (end - str.data()) + 1, ctx.next_arg_id()};
~ ~~~~^~~~~~~~~~~~
include/fmt/compile.h:538:31: note: in instantiation of function template specialization
'fmt::v7::detail::parse_specs<int, char>' requested here
constexpr auto result = parse_specs<id_type>(str, POS + 2, ID);
^
include/fmt/compile.h:569:17: note: in instantiation of function template specialization
'fmt::v7::detail::compile_format_string<fmt::v7::detail::type_list<int>, 0, 0, FMT_COMPILE_STRING>' requested here
detail::compile_format_string<detail::type_list<Args...>, 0, 0>(
^
include/fmt/compile.h:648:37: note: in instantiation of function template specialization
'fmt::v7::detail::compile<int, FMT_COMPILE_STRING, 0>' requested here
constexpr auto compiled = detail::compile<Args...>(S());
^
test/compile-test.cc:140:24: note: in instantiation of function template specialization
'fmt::v7::format<FMT_COMPILE_STRING, int, 0>' requested here
EXPECT_EQ("42", fmt::format(FMT_COMPILE("{:x}"), 0x42));
^
In file included from test/compile-test.cc:16:
include/fmt/compile.h:518:25: error: implicit conversion changes signedness: 'long' to 'unsigned long' [-Werror,-Wsign-conversion]
return {f, pos + (end - str.data()) + 1, ctx.next_arg_id()};
~ ~~~~^~~~~~~~~~~~
include/fmt/compile.h:538:31: note: in instantiation of function template specialization
'fmt::v7::detail::parse_specs<char [4], char>' requested here
constexpr auto result = parse_specs<id_type>(str, POS + 2, ID);
^
include/fmt/compile.h:494:27: note: in instantiation of function template specialization
'fmt::v7::detail::compile_format_string<fmt::v7::detail::type_list<int, int, char const (&)[4], int>, 5, 2, FMT_COMPILE_STRING>'
requested here
constexpr auto tail = compile_format_string<Args, POS, ID>(format_str);
^
include/fmt/compile.h:539:14: note: in instantiation of function template specialization
'fmt::v7::detail::parse_tail<fmt::v7::detail::type_list<int, int, char const (&)[4], int>, 5, 2, fmt::v7::detail::spec_field<char, int, 0>, FMT_COMPILE_STRING>' requested here
return parse_tail<Args, result.end, result.next_arg_id>(
^
include/fmt/compile.h:569:17: note: in instantiation of function template specialization
'fmt::v7::detail::compile_format_string<fmt::v7::detail::type_list<int, int, char const (&)[4], int>, 0, 0, FMT_COMPILE_STRING>'
requested here
detail::compile_format_string<detail::type_list<Args...>, 0, 0>(
^
include/fmt/compile.h:648:37: note: in instantiation of function template specialization
'fmt::v7::detail::compile<int, int, char const (&)[4], int, FMT_COMPILE_STRING, 0>' requested here
constexpr auto compiled = detail::compile<Args...>(S());
^
test/compile-test.cc:145:18: note: in instantiation of function template specialization
'fmt::v7::format<FMT_COMPILE_STRING, int, int, char const (&)[4], int, 0>' requested here
fmt::format(FMT_COMPILE("{:{}}{:{}}"), 42, 4, "foo", 5));
^
2 errors generated.
Solution:
- Explicitly cast the result of the subtraction to the (unsigned) outer
type.
Co-authored-by: Jonathan Gopel <jgopel@quantlab.com>
Using sizeof causes some compilers to complain:
'operand of sizeof is not a type, variable, or dereferenced pointer'
static_cast itself should be enough to silence unused variable warning
Co-authored-by: Łukasz Mitka <lukasz.mitka@aptiv.com>
Changed the clz implementations to use xor instead of subtraction so that when
count_digits "undoes" the BSR -> CLZ translation, the optimizer is more
willing to recognize the equivalence.
Changed the data array in bsr2log10 to static since otherwise MSVC generates
code to build the array every time the function is called.
* add forgotten template argument to make_format_args which made some uses of FMT_COMPILE not work anymore after 54daa0864a, add more elaborate test cases to compile-test as regression tests
* fix old-style cast which gcc on travis thankfully doesn't accept anymore
* hopefully last forgotten (void*)
* Disable fallthrough attributes for the Intel compilers
On MacOS and Linux the Intel compilers may be identified as the
host compilers (Clang or GNU) but do not support the corresponding
compiler specific fallthrough attributes.
* Rearrange ifdef logic for excluding pre-C++17 fallthrough attributes
This puts Intel and PGI compilers into a separate group
and thus makes the intent and logic more obvious.
* add support for fallback_formatter in detail::write
* add ToString test into OStreamTest
to check fmt::to_string() with class that has output stream operator
* add WithOstreamOperator test into CompileTest
to check fmt::format() with FMT_COMPILE() and class that has output stream operator
* use conditional_t inside detail::write instead of 2 overloads
* Revert "add WithOstreamOperator test into CompileTest"
* remove Context from template parameters in detail::write
The intel-19 compiler warns about hidden variables:
```
/s/dev/nightly/libraries/ioss/src/fmt/format.h(2689): warning #1599: declaration hides variable "begin" (declared at line 2668)
FMT_CONSTEXPR void operator()(const Char* begin, const Char* end) {
^
detected during:
instantiation of "Context::iterator fmt::v7::vformat_to<ArgFormatter,Char,Context>(ArgFormatter::iterator, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<Context>, fmt::v7::detail::locale_ref) [with ArgFormatter=fmt::v7::detail::arg_formatter<fmt::v7::detail::buffer_appender<char>, char>, Char=char, Context=fmt::v7::format_context]" at line 3492
instantiation of "fmt::v7::detail::buffer_appender<Char> fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<Char> &, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char>>, fmt::v7::type_identity_t<Char>>>) [with Char=char]" at line 1413 of "/s/dev/nightly/libraries/ioss/src/fmt/format-inl.h"
/s/dev/nightly/libraries/ioss/src/fmt/format.h(2689): warning #1599: declaration hides variable "end" (declared at line 2669)
FMT_CONSTEXPR void operator()(const Char* begin, const Char* end) {
^
detected during:
instantiation of "Context::iterator fmt::v7::vformat_to<ArgFormatter,Char,Context>(ArgFormatter::iterator, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<Context>, fmt::v7::detail::locale_ref) [with ArgFormatter=fmt::v7::detail::arg_formatter<fmt::v7::detail::buffer_appender<char>, char>, Char=char, Context=fmt::v7::format_context]" at line 3492
instantiation of "fmt::v7::detail::buffer_appender<Char> fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<Char> &, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char>>, fmt::v7::type_identity_t<Char>>>) [with Char=char]" at line 1413 of "/s/dev/nightly/libraries/ioss/src/fmt/format-inl.h"
```
Rename the second set of variables to `pbegin` and `pend` to eliminate warning.
Our nvcc compilers (10.1.243 and 9.2.X) do not define the correct value for `FMT_USE_UDL_TEMPLATE` and then end up with an error later on in the build. Explicitly search for `__NVCC__` symbol not being defined. Might want to instead use `FMT_NVCC` or some other check, but the raw `__EDG_VERSION__` check is not working correctly for nvcc.
* include/fmt/format.h: int_writer: removed unnecessary iterator type re-declaration (prevents shadow-waringing in clang)
* include/fmt/format.h: int_writer: correctly cast signed integer to unsigned to prevent 'implicit conversion changes signedness'-warnings in clang.
Co-authored-by: Martin Wührer <martin.wuehrer@artech.at>
clang-cl currently has a long-standing bug that using 128 bit integers
generates references to symbols that are provided neither by its own nor
by the Microsoft runtime: https://bugs.llvm.org/show_bug.cgi?id=25305
clang-cl currently has a long-standing bug that using 128 bit integers
generates references to symbols that are provided neither by its own nor
by the Microsoft runtime: https://bugs.llvm.org/show_bug.cgi?id=25305