This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: glibc segfault on "special" long double values is _ok_!?


On Thu, Jun 07, 2007 at 12:10:26PM +0200, Jan-Benedict Glaw wrote:
> On Wed, 2007-06-06 22:44:17 +0100, James Youngman <jay@gnu.org> wrote:
> > If I read a stream of data (from a file, a network socket, etc.) which
> > is supposed to contain valid floating-point data, it is reasonable for
> > a program to print it.  Especially so if the printing I am doing is a
> 
> Data you didn't compute yourself isn't supposed to contain anything
> known. Each and every bit may contain something you didn't expect,
> that's why you have to do input checking.
> 
> The most you can do with your externally fetched data is printing it
> out, byte by byte, in hex. "Assuming" that this'll make up any
> well-known data formats is just asking for trouble.

Passing long doubles in binary form can't be portable, there are just way
too many different formats, endianity etc. (IEEE 754 double, quad, IEEE 854
extended double, the same with Intel extensions, IBM long double format
to name just a few, in many cases with various endian encodings and
sometimes with different padding).  Using text representation (best
the ISO C99 hexadecimal float format) is much wiser.

	Jakub


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