[PATCH] libstdc++: Make make_decimalN inline instead of static [PR122071]
Jonathan Wakely
jwakely@redhat.com
Wed Sep 9 10:05:18 GMT 2026
On Tue, 8 Sept 2026 at 21:21, Sammy Al Hashemi <sammy@salh.xyz> wrote:
>
> Ah yes, my mistake. I will remove this from the commit message. What is the typical workflow to remedy this sort of mistake? Create a v2 patch?
Yes, or since this is just a change to the commit message, you could
just provide a revised commit message in an email and I can use that
when committing.
>
> On Tue, Sep 8, 2026, at 1:44 PM, Jonathan Wakely wrote:
>
> Thanks for working on this!
>
> On Tue, 8 Sept 2026, 20:36 Sammy Al Hashemi, <sammy@salh.xyz> wrote:
>
> The make_decimal32/64/128 overloads in <decimal/decimal.h> were declared
> static at namespace scope in a header, so every translation unit that
> included it got its own copy. That causes code bloat and the internal
> linkage also prevents inlining.
>
>
> Does it?
>
> It prevents them from being used in modules, but I don't see how it prevents inlining.
>
>
> Declaring them inline instead gives
> them external linkage with vague-linkage semantics, fixing both.
>
> libstdc++-v3/ChangeLog:
>
> PR libstdc++/122071
> * include/decimal/decimal.h (make_decimal32): Make inline
> instead of static.
> (make_decimal64): Likewise.
> (make_decimal128): Likewise.
>
> Signed-off-by: Sammy Al Hashemi <sammy@salh.xyz>
> ---
> libstdc++-v3/include/decimal/decimal.h | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/libstdc++-v3/include/decimal/decimal.h b/libstdc++-v3/include/decimal/decimal.h
> index f18fbffa83b..37d17ba4d68 100644
> --- a/libstdc++-v3/include/decimal/decimal.h
> +++ b/libstdc++-v3/include/decimal/decimal.h
> @@ -120,7 +120,7 @@ namespace decimal
>
> // ISO/IEC TR 24733 3.2.5 Initialization from coefficient and exponent.
>
> - static decimal32 make_decimal32(long long __coeff, int __exponent)
> + inline decimal32 make_decimal32(long long __coeff, int __exponent)
> {
> decimal32 __decexp = 1, __multiplier;
>
> @@ -138,7 +138,7 @@ namespace decimal
> return __coeff * __decexp;
> }
>
> - static decimal32 make_decimal32(unsigned long long __coeff, int __exponent)
> + inline decimal32 make_decimal32(unsigned long long __coeff, int __exponent)
> {
> decimal32 __decexp = 1, __multiplier;
>
> @@ -156,7 +156,7 @@ namespace decimal
> return __coeff * __decexp;
> }
>
> - static decimal64 make_decimal64(long long __coeff, int __exponent)
> + inline decimal64 make_decimal64(long long __coeff, int __exponent)
> {
> decimal64 __decexp = 1, __multiplier;
>
> @@ -174,7 +174,7 @@ namespace decimal
> return __coeff * __decexp;
> }
>
> - static decimal64 make_decimal64(unsigned long long __coeff, int __exponent)
> + inline decimal64 make_decimal64(unsigned long long __coeff, int __exponent)
> {
> decimal64 __decexp = 1, __multiplier;
>
> @@ -192,7 +192,7 @@ namespace decimal
> return __coeff * __decexp;
> }
>
> - static decimal128 make_decimal128(long long __coeff, int __exponent)
> + inline decimal128 make_decimal128(long long __coeff, int __exponent)
> {
> decimal128 __decexp = 1, __multiplier;
>
> @@ -210,7 +210,7 @@ namespace decimal
> return __coeff * __decexp;
> }
>
> - static decimal128 make_decimal128(unsigned long long __coeff, int __exponent)
> + inline decimal128 make_decimal128(unsigned long long __coeff, int __exponent)
> {
> decimal128 __decexp = 1, __multiplier;
>
> --
> 2.55.0
More information about the Libstdc++
mailing list