Skip to content

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

Merged
guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:codegen-locale-independent-literals
Sep 3, 2026
Merged

[RF] Make the code emitted by codegen locale-independent#23210
guitargeek merged 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

@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.

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
@guitargeek
guitargeek force-pushed the codegen-locale-independent-literals branch from 77488f1 to c01f473 Compare September 3, 2026 11:24

@dpiparo dpiparo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks.

@guitargeek
guitargeek merged commit 24fbb8b into root-project:master Sep 3, 2026
26 of 31 checks passed
@guitargeek
guitargeek deleted the codegen-locale-independent-literals branch September 3, 2026 14:08
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.

2 participants