-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about fmt::format_error with -fno-exceptions #2146
Comments
I would say it is better to completely avoid use of any Use of any class derived from
Using library functions takes more space in |
It will be nice to have something like
|
That's an interesting idea but I'd rather not do it unless folks who are using |
First of all, I need to say that I have close to zero experience with C++ without exceptions (
-fno-exceptions
), so I may be somehow wrong here. Also, I want to note that currently {fmt} should not be used with exceptions disabled (in my opinion) because it does not provide a proper error handling interface, likeerror_code
orresult<T>
/outcome
. But we have what we have.Looking at #2145, I realized that there is no need to derive
format_error
fromstd::runtime_error
when exceptions are disabled. Of course, we are able to do this, butstd
exception classes are kinda heavy even in this case. Maybe some custom class that provides constructor (onlyconst char*
needed) andwhat()
method is enough.Here is a simplified example on Compiler Explorer, and sizes are 190kB for derived
exception
vs. 44kB for customexception
. I also prepared a benchmark for that example on QuickBench. But this benchmark can only show that there is no performance regression for correct usages and that incorrect usages with customexception
results in faster program failure, nothing interesting.Is it worth changing
format_error
that way?The text was updated successfully, but these errors were encountered: