Skip to content

Fix exception formatters with exceptions disabled - #4904

Merged
vitaut merged 1 commit into
fmtlib:mainfrom
cjacek:no-exceptions
Sep 7, 2026
Merged

Fix exception formatters with exceptions disabled#4904
vitaut merged 1 commit into
fmtlib:mainfrom
cjacek:no-exceptions

Conversation

@cjacek

@cjacek cjacek commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Fixes building with Clang 20 and older with -fno-exceptions, which treats try/catch usage as an error.

Fixes FEX builds: FEX-Emu/FEX#5870

@vitaut vitaut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, but I don’t think we should disable the std::exception formatter itself. Instead, please disable only the minimal part that relies on try/catch. Also, could you post the full compiler error message?

@cjacek

cjacek commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The new version disables only minimal part of std::exception formatter. for exception_ptr, it seems that there would be nothing left if I did that. I also considered using FMT_TRY/FMT_CATCH, but that would just be broken with disabled exceptions.

The error message is:

fmt/include/fmt/std.h:685:9: error: cannot use 'try' with exceptions disabled
fmt/include/fmt/std.h:704:5: error: cannot use 'try' with exceptions disabled

Here is a compiler explorer repro: https://godbolt.org/z/7jKncahEK

It's specific to usage in templates that's now allowed. Outside templates it's always an error.

Comment thread include/fmt/std.h Outdated
…tions are disabled.

Fixes building with Clang 20 and older with -fno-exceptions, which treats
try/catch usage as an error.
@vitaut vitaut changed the title Disable std::exception formatter when exceptions are disabled. Fix exception formatters with exceptions disabled Sep 7, 2026
@vitaut
vitaut merged commit c07e2aa into fmtlib:main Sep 7, 2026
47 checks passed
@vitaut

vitaut commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Merged, thanks

@cjacek
cjacek deleted the no-exceptions branch September 7, 2026 14:21
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

Successfully merging this pull request may close these issues.

2 participants