Changes to glibc function strtod in RHEL6 result in unexpected results

Solution Verified - Updated -

Issue

  • Program running into errors referencing the strtod function
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>

int main()
{
    char* s = "1.00000000000000e-308";
    char* endptr;
    double ret;

    errno = 0;
    ret = strtod(s, &endptr);

    if (errno) {
        if (errno == ERANGE)
            printf("Error: ERANGE(%s)\n.", strerror(errno));
        else
            printf("Error: other (%s)\n", strerror(errno));
    } else {
        printf("Success: %lf.\n", ret);
    }

    return 0;

Works on Redhat 5.5 with the following output

[root@box lubo]# ./fl
Success: 0.000000.

Fails on Redhat 6.2 with the following output

[root@box tmp]# ./fl
Error: ERANGE(Numerical result out of range)

Environment

  • Red Hat Enterprise Linux 6

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In