[PATCH v2] libstdc++: Make make_decimalN inline instead of static [PR122071]
Jonathan Wakely
jwakely@redhat.com
Wed Sep 9 20:25:00 GMT 2026
On Wed, 9 Sept 2026 at 16:06, Sammy Al Hashemi <sammy@salh.xyz> wrote:
>
> The make_decimal32/64/128 overloads in <decimal/decimal.h> were declared
> static at namespace scope, which gives them internal linkage. An entity
> with internal linkage cannot be exported, so these functions are not
> usable from modules when the header is consumed as a header unit or
> included in a module purview. Internal linkage also means every
> translation unit including the header gets its own copy of each
> function, each with a distinct address.
>
> Declaring them inline instead gives them external linkage with
> vague-linkage semantics: a single entity shared across translation
> units, which can be exported.
Thanks, I've pushed this to trunk now.
>
> 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