Thanks for working on this!

On Tue, 8 Sept 2026, 20:36 Sammy Al Hashemi, <[email protected]> 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 <[email protected]>
> ---
>  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
>
>

Reply via email to