Skip to content

[RF] Make the code emitted by codegen locale-independent - #23210

Open
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:codegen-locale-independent-literals
Open

[RF] Make the code emitted by codegen locale-independent#23210
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:codegen-locale-independent-literals

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

The codegen backend formats the numbers it writes into the generated C++ with default-constructed streams, which follow the global locale. Under a comma-decimal locale (a German one, say) the emitted literals came out as "0,5": that does not compile, and inside a call argument list the comma even turns one argument into two, so the generated code silently changes meaning instead of failing.

Imbue the classic locale on every stream whose output ends up in the generated code: CodegenImpl's doubleToString(), which formats the value of RooConstVar/RooRealVar and the analytical integrals, plus CodegenContext's buildArg() for double arguments, buildArgSpanImpl() for the emitted arrays (where a grouping separator would corrupt integers the same way), and the stream that renders the node descriptions into the code comments.

Add a regression test that generates the code for a RooGaussian with constant parameters and for a RooChebychev (whose observable range is passed to the generated call as a plain double) under a comma-decimal locale, built from a custom numpunct facet because no such OS locale is installed everywhere. Both must produce exactly the code they produce under the classic locale. This is the first test for the codegen package, so it also adds roofit/codegen/test/.

🤖 Done with the help of AI

The codegen backend formats the numbers it writes into the generated C++
with default-constructed streams, which follow the global locale. Under a
comma-decimal locale (a German one, say) the emitted literals came out as
"0,5": that does not compile, and inside a call argument list the comma
even turns one argument into two, so the generated code silently changes
meaning instead of failing.

Imbue the classic locale on every stream whose output ends up in the
generated code: CodegenImpl's doubleToString(), which formats the value
of RooConstVar/RooRealVar and the analytical integrals, plus
CodegenContext's buildArg() for double arguments, buildArgSpanImpl() for
the emitted arrays (where a grouping separator would corrupt integers the
same way), and the stream that renders the node descriptions into the
code comments.

Add a regression test that generates the code for a RooGaussian with
constant parameters and for a RooChebychev (whose observable range is
passed to the generated call as a plain double) under a comma-decimal
locale, built from a custom numpunct facet because no such OS locale is
installed everywhere. Both must produce exactly the code they produce
under the classic locale. This is the first test for the codegen package,
so it also adds roofit/codegen/test/.

🤖 Done with the help of AI
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Test Results

    21 files      21 suites   3d 12h 45m 18s ⏱️
 3 861 tests  3 860 ✅ 0 💤 1 ❌
72 051 runs  72 049 ✅ 1 💤 1 ❌

For more details on these failures, see this check.

Results for commit 77488f1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant