bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: glibc segfault on "special" long double values is _ok_!?


From: Tor Myklebust
Subject: Re: glibc segfault on "special" long double values is _ok_!?
Date: Thu, 7 Jun 2007 13:57:17 -0400 (EDT)

On Thu, 7 Jun 2007, Jan-Benedict Glaw wrote:

There's a difference in

        void send_float (float foo, int fd) {
                write (fd, &foo, sizeof (float));
        }

and

        void send_float (float foo, int fd) {
                char buf[100];
                snprintf (buf, sizeof (buf), "%f", foo);
                write (fd, buf, strlen (buf));
        }

The second variant surely burns more CPU cycles, even on both sides,
but it'll easily work even for different architectures. (I just think
about VAX where the CPU FP support is made up of four non-IEEE float
types...)

And the second variant can segfault if you replace 'float' by 'long double' (changing the format string appropriately) and you feed it something bad. Why is this a good thing?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]