Skip to content
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

code bloat: float writing code built but not used #1557

Closed
ghost opened this issue Feb 19, 2020 · 4 comments
Closed

code bloat: float writing code built but not used #1557

ghost opened this issue Feb 19, 2020 · 4 comments

Comments

@ghost
Copy link

ghost commented Feb 19, 2020

I'm trying to use fmtlib in an embedded environment (Arm Cortex M4 w/64kB of code space). Adding a single use of fmtlib (fmt::format("the answer is {}", 42)), about 30kB of code is generated. This is after FMT_STATIC_THOUSANDS_SEPARATOR is used (otherwise over 100kB of code is generated) and appropriately configured toolchains.

Looking into it, I see that a large amount of code related to formatting floating point numbers is included, despite it not being used. Does anyone know why this might be?

@vitaut
Copy link
Contributor

vitaut commented Feb 23, 2020

This is expected. fmt::format, as printf, needs to know how to format all built-in types including floating-point numbers.

@vitaut vitaut closed this as completed Feb 23, 2020
@ghost
Copy link
Author

ghost commented Mar 9, 2020

While I understand that some hypothetical compiler might come along and prove to itself that not all built-in types are actually formatted in some given program, wouldn't it be better for fmt::format to internally "dispatch", based on the types of arguments passed to it, to internal variants that each know how to format some subset of the available types?

@vitaut
Copy link
Contributor

vitaut commented Mar 9, 2020

In general it's not possible because format strings can be provided at runtime. However, it will be possible with format string compilation which is currently WIP.

@vitaut
Copy link
Contributor

vitaut commented Mar 20, 2020

#1590 allows disabling floating point support.

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

No branches or pull requests

1 participant