Skip to content

Fix f32 and f64 constant literal generation in cc_bindings_from_rs. - #2372

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_999619545
Open

copybara-service[bot] wants to merge 1 commit into
mainfrom
test_999619545

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Fix f32 and f64 constant literal generation in cc_bindings_from_rs.

Format finite f32 and f64 constants from their raw ScalarInt bits using Rust's shortest round-trip debug float formatter ({value:?}f and {value:?}) instead of rustc_apfloat Display and format_float, which suffixed f64 (double) literals with L (long double), emitted non-minimal decimal representations, and formatted non-finite values as invalid C++ tokens (+Inf.0f, NaN.0f). Emit Clang/GCC constexpr builtins (__builtin_inf[f]() and __builtin_nan[s][f](...)) for infinities and NaNs while preserving sign, quiet/signaling bits, and payloads, and remove the unsupported_consts workaround for core::{f32,f64}::{INFINITY,NEG_INFINITY,NAN}.

@copybara-service
copybara-service Bot force-pushed the test_999619545 branch 4 times, most recently from 56650e3 to c7dd552 Compare November 11, 2026 13:43
Format finite `f32` and `f64` constants from their raw `ScalarInt` bits using Rust's shortest round-trip debug float formatter (`{value:?}f` and `{value:?}`) instead of `rustc_apfloat` `Display` and `format_float`, which suffixed `f64` (`double`) literals with `L` (`long double`), emitted non-minimal decimal representations, and formatted non-finite values as invalid C++ tokens (`+Inf.0f`, `NaN.0f`). Emit Clang/GCC `constexpr` builtins (`__builtin_inf[f]()` and `__builtin_nan[s][f](...)`) for infinities and NaNs while preserving sign, quiet/signaling bits, and payloads, and remove the `unsupported_consts` workaround for `core::{f32,f64}::{INFINITY,NEG_INFINITY,NAN}`.

PiperOrigin-RevId: 999619545

This branch has not been deployed

No deployments
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.

1 participant