This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [libstdc++] preliminary headers supporting decimal float in C++


On Tue, 2009-09-29 at 14:23 -0700, Janis Johnson wrote:
> On Tue, 2009-09-29 at 13:49 -0700, Benjamin Kosnik wrote:
> > > +  // ISO/IEC TR 24733  3.2.6  Conversion to generic floating-point
> > > type.
> > > +  float decimal32_to_float (decimal32 d);
> > > +  float decimal64_to_float (decimal64 d);
> > > +  float decimal128_to_float (decimal128 d);
> > > +  float decimal_to_float (decimal32 d);
> > > +  float decimal_to_float (decimal64 d);
> > > +  float decimal_to_float (decimal128 d);
> > > +
> > > +  double decimal32_to_double (decimal32 d);
> > > +  double decimal64_to_double (decimal64 d);
> > > +  double decimal128_to_double (decimal128 d);
> > > +  double decimal_to_double (decimal32 d);
> > > +  double decimal_to_double (decimal64 d);
> > > +  double decimal_to_double (decimal128 d);
> > > +
> > > +  long double decimal32_to_long_double (decimal32 d);
> > > +  long double decimal64_to_long_double (decimal64 d);
> > > +  long double decimal128_to_long_double (decimal128 d);
> > > +  long double decimal_to_long_double (decimal32 d);
> > > +  long double decimal_to_long_double (decimal64 d);
> > > +  long double decimal_to_long_double (decimal128 d);
> > > +
> > 
> > I have real questions about this C compatibility.
> 
> Yes, me too.
> 
> > From C++ N2849, usability intent remains obscured at least to me.
> > 
> > First, all these functions are declared with C++ linkage. Are C
> > programmers to call the mangled name? After including the C++ header
> > <decimal>? Why would any C programmer do this instead of
> > casting? 
> > 
> > Second, overloaded functions like decimal_to_float, decimal_to_double,
> > decimal_to_long_double are not actionable within C. Only the explicitly
> > named functions like decimal32_to_float will be usable. Maybe this is
> > just a typo in the standard.
> 
> I'll pass it on to the TR's author.  The TR has been approved, by the
> way, and the latest version, dated 2009-08-28, doesn't have an "N"
> document number.

I've got a better response to this now.

These functions are not there for C compatibility, they are the only way
provided in C++ to convert from a decimal float-point value to a generic
floating-point value.  The section on C compatibility that talks about
these functions is referring to source compatibility, recommending that
C code use a variant of these functions instead of casts or implicit
conversions during assignment to convert from decimal to generic
floating-point.  Perhaps the hope is that the C people will add these
to a later version of the C TR, or a hint that a programmer can provide
her own versions of these for use with C code.  In any case, the intent
is not for C code to somehow call these C++ functions.

Janis


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]