2201 Commits

Author SHA1 Message Date
Victor Zverovich
26c01df3bd Handle const-qualified named arguments
A named argument that arrives const-qualified was not recognized by
is_named_arg, silently dropping its name. This happens both when a
named argument is passed through an intermediate function returning
const T& (https://github.com/fmtlib/fmt/issues/4866) and in fmt's own
compiled format path, which passes arguments as const T&.

Make is_named_arg and is_static_named_arg see through top-level const so
the name is preserved instead of dropped.
2026-07-29 09:20:23 -07:00
Victor Zverovich
90567e92d4 Exercise compiled field path in FMT_COMPILE format_as test
The FMT_COMPILE("{}") format string takes a to_string fast path that
never runs the compiled field code the format_as fix (#4836) touched.
Use "[{}]" so the test actually goes through detail::field::format.
2026-07-23 13:35:44 -07:00
Victor Zverovich
c851fbe658 Apply clang-format 2026-07-23 13:10:37 -07:00
Victor Zverovich
4e5ff510f8 Simplify build-tree export and rename INSTALL_TARGETS
Rename INSTALL_TARGETS to FMT_TARGETS since the list is now used for both
installation and the build-tree export, and move INSTALL_FILE_SET into the
FMT_INSTALL block as only install(TARGETS) uses it.

Replace the export-test static library and export-lib.cc with an INTERFACE
library, which reproduces the same CMake export dependency check (#4806).
2026-07-22 11:24:25 -07:00
hexonal
a749e9d880
Generate CMake export set regardless of FMT_INSTALL (#4850)
export() was scoped inside if (FMT_INSTALL), so projects that pull in
fmt via add_subdirectory()/FetchContent without installing it had no
way to get the exported fmt::* targets. If such a project tries to
export its own targets that depend on fmt, CMake fails with "target
... requires target fmt that is not in any export set".

Hoist the target list/export name and the export() call itself out of
the FMT_INSTALL guard so the build-tree export file is always
generated; the install()-only pieces (config/version files, pkgconfig,
install(EXPORT ...)) stay behind the guard and installed behavior is
unchanged.

Fixes #4806

Co-authored-by: flink <w741069229@gmail.com>
2026-07-20 15:09:34 -07:00
Victor Zverovich
b5d1e5404b Annotate FMT_USE_RTTI #endif directives
Add trailing "// FMT_USE_RTTI" comments to the matching #endif lines to make
the conditional-compilation blocks easier to follow.
2026-07-17 12:12:25 -07:00
Victor Zverovich
7852fc384c Fix out-of-range integers with the 'c' presentation type (#4839)
Formatting an integer with ':c' used the magnitude (abs_value) and never
range-checked, so negatives were mangled and out-of-range values silently
truncated. Copy the value as a character and report an error when it is out
of range, treating all character types as unsigned for portability.
2026-07-17 11:36:52 -07:00
AMAN UPADHYAY
af2d9f2b78
Fix FMT_COMPILE failure with format_as mapped types (Issue #4794) (#4836) 2026-07-12 09:21:55 -07:00
Avi Kivity
1a99c2630c
Format nested exceptions in std::exception formatter (#4844)
Detect when a std::exception also derives from std::nested_exception
(e.g. via std::throw_with_nested) and unwind the whole chain, joining
each level with ": ". The type-name flag ({:t}) is honored at every
level, and the std::exception_ptr formatter inherits this behavior.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 08:50:10 -07:00
Victor Zverovich
9d13c41ce6 Format null std::exception_ptr as "none"
Change the null exception_ptr representation from "nullptr" to "none" to
convey the "no exception" state more clearly, and update the test.
2026-07-11 08:21:32 -07:00
Jan
6dac6cad05
feat: add formatter for std::exception_ptr (#4808) (#4819) 2026-07-05 09:22:18 -07:00
Victor Zverovich
d24fef27d1 Minor cleanup 2026-06-26 15:57:41 -07:00
Victor Zverovich
a2206152d5 Simplify test 2026-06-26 12:29:26 -07:00
Jan Engelhardt
719823cc64
Turn libfmt-c into a shared library (#4812)
Linux distros don't like having static archives. Set fmt-c to shared
just like the main fmt library.
2026-06-26 06:55:44 -07:00
Yat Ho
0e601c34de
fix: explicitly check operator[] in is_contiguous (#4825)
Prevent false positives when the container itself does not have `operator[](size_t)`, but the target type of one of the non-explicit user-defined conversion functions does.
2026-06-25 12:21:59 -07:00
Vinay Kumar
588b3a0f8f
Fix fallback uint128 bitwise not (#4813) 2026-06-17 23:52:12 -07:00
Victor Zverovich
979c94dff8 Fix hang/assertion when printing to a pipe with closed read end (#4797) 2026-06-18 08:08:44 +02:00
aizu-m
de4c6c502e
fix out-of-range float to int conversion in to_nonnegative_int (#4802) 2026-06-16 23:14:58 -07:00
aizu-m
128ba144ab
fix out-of-bounds read in basic_format_args::get (#4800) 2026-06-09 22:18:35 -07:00
Victor Zverovich
c1c7296bfa Add a test for fmt_print 2026-06-08 08:18:43 +02:00
Jiami Lin
a90ad5d6fd
Fix formatting std::tm with null tm_zone (#4790) 2026-06-01 18:16:49 -07:00
Victor Zverovich
46cf422f54 Unify copyright notices 2026-05-31 08:54:06 -07:00
j4niwzis
029d543768
Fix compile time format for ranges, style, and std (#4759) 2026-05-31 08:21:35 -07:00
ahoarau
0acf106c52
Add println functions for formatted output with color support (#4782) 2026-05-25 08:30:36 -07:00
Vladislav Shchapov
a30cf7d1ad
Provide reasonable default definition for is_contiguous (#4770)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2026-05-21 07:19:19 -07:00
Vladislav Shchapov
9cb8c0f92b
Fix ambiguous formatter<std::optional<T>> between fmt/std.h and fmt/ranges.h on C++26 (P3168R2) (#4761)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2026-05-03 07:37:46 -07:00
Kağan Can Şit
d0e3d20af8
chore(IWYU):Remove redundant includes (#4758) 2026-04-29 20:50:56 -07:00
user202729
eeff8680ed
Avoid dropping null byte in format string (#4732)
* Avoid dropping null byte in format string

* Add a test for null byte in format string
2026-04-23 09:34:27 -07:00
Victor Zverovich
382609a920 Cleanup module test and CI config 2026-04-14 12:30:21 -07:00
Mathew Benson
8783c3c2d4
enable fmt_module tests by updating module-test.cc (#4702)
- Update g++ module testing to use g++ version 15 instead of 14.
  The module support in version 14 isn't very stable and the module
  testing was not working due to unresolved locale symbols.
- Update CI for linux and macos to add verbosity so its consistent with
  windows.
- Refactor test/CMakeLists.txt to enable testing for modules
- The tests in `module-test.cc` seem to not have been updated in some
  time despite changes in the main library.
- Wide String versions of several tests appear to be deprecated so have
  been removed.
- Refactored tests related to `fmt::format_args` that now requires lvalue
  references as opposed to direct values.
- Remove the none-working code identified in the `module-test.cc` file
  while updating.
2026-04-12 10:07:16 -07:00
Raúl Marín
4ccf1d4faf
Fix out-of-bounds read in vprintf with trailing '%' (#4742) 2026-04-10 12:23:57 -07:00
Kağan Can Şit
9396f77fe4
Remove unused header includes in test files (#4729) 2026-04-05 18:40:48 -07:00
Victor Zverovich
8572a24603 Cleanup CI config 2026-04-02 15:04:00 -07:00
Victor Zverovich
602df7dab8 Simplify copy 2026-03-28 09:33:45 -07:00
Victor Zverovich
dc05bee307 Don't assume nul termination in printf
Thanks ZUENS2020 for reporting.
2026-03-23 13:28:26 -07:00
sunmy2019
ea85b81ccd
Support fmt::runtime with wchar_t in fmt::format_to_n (#4715) 2026-03-21 17:10:17 -07:00
Victor Zverovich
d38881410a Deprecated initializer_list join 2026-03-05 16:42:07 -08:00
Yancey
8277ee6aa0
Update fmt::join to support more character types (#4686) 2026-03-04 08:14:08 -08:00
Victor Zverovich
e090e3ffad Apply cmake-format 2026-03-03 15:49:40 -08:00
Victor Zverovich
eef9ff4938 Fix module test 2026-03-03 12:53:45 -08:00
Victor Zverovich
011b24123b Cleanup module test 2026-03-03 12:30:54 -08:00
Mathew Benson
4e1b170b44
Add Separate CMake Target for C++20 Modules (#4685)
* Add Separate CMake Target for C++20 Modules

In the same vein as there is the `fmt::fmt-header-only`, `fmt::fmt` and
`fmt::fmt_c` targets, I propose the addition of a new target
`fmt::fmt-module` which will be for the compilation of the FMT_MODULE
library option.

The new target will have the properties requried for Compiling,
Installing and using the C++20 functionality in CMake

The `add_module_library` function is marked as deprecated as its
functionality is superseded.

Updated the logic for setting the FMT_USE_CMAKE_MODULE flag to check the
versions for Ninja and MSVC according the CMAKE Documents and setting
the FMT_MODULE flag based on this

* Add Separate CMake Target for C++20 Modules

In the same vein as there is the `fmt::fmt-header-only`, `fmt::fmt` and
`fmt::fmt_c` targets, I propose the addition of a new target
`fmt::fmt-module` which will be for the compilation of the FMT_MODULE
library option.

The new target will have the properties requried for Compiling,
Installing and using the C++20 functionality in CMake

Updated the logic for setting the FMT_USE_CMAKE_MODULE flag to check the
versions for Ninja and MSVC according the CMAKE Documents and setting
the FMT_MODULE flag based on this

Fixed the test/CMakeLists.txt file which used the FMT_MODULE flag to
separate the module and non-module library testing, in particular
disableing the module version.

The module testing still needs to be fixed, but the expected behavior of
testing the non-modular version is working.

---------

Co-authored-by: Mathew Benson <mathew@benson.co.ke>
Co-authored-by: ClausKlein <claus.klein@arcormail.de>
2026-03-02 09:11:31 -08:00
Victor Zverovich
dc97113ca1 Cleanup the C API 2026-02-21 17:15:19 -08:00
Soumik15630m
1dc644e021
Add C11 API with type-safe formatting (#4663) (#4671) 2026-02-16 07:06:32 -08:00
Stéén
b35de87ad9
std.h: Allow formatting std::unexpected type. (#4675)
In some cases, people might want to format the std::unexpected type itself,
independent of the value type, this commit makes it possible.

Co-authored-by: Robin Oger <robin.oger.work@gmail.com>
2026-02-11 15:06:59 -08:00
Victor Zverovich
eb99f6eba6 Move std::byte formatter to std.h 2026-02-03 10:16:20 -08:00
Victor Zverovich
b98926b73b uint128_fallback -> uint128 2026-02-02 19:13:14 -08:00
Victor Zverovich
3f98b54bd7 Move _BitInt next to bitref formatter 2026-02-02 17:08:10 -08:00
Victor Zverovich
45ed657df3 Cleanup locking 2026-02-01 11:09:19 -08:00
Victor Zverovich
76d480c6fd Cleanup handling of adaptors 2026-01-31 19:49:52 -08:00