stdcxx-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STDCXX-862) [Sun C++ 5.9] 0.char test failed due to different binary representation of "long double ld1 = 0" and "long double ld2 = 0."
Date Tue, 15 Apr 2008 21:00:21 GMT

    [ https://issues.apache.org/jira/browse/STDCXX-862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12589231#action_12589231
] 

Martin Sebor commented on STDCXX-862:
-------------------------------------

The program below shows the bit pattern generated by the compiler. gcc 3.4.1 running on the
same machine generates all zeros. {noformat}
$ cat t.cpp && CC -O -V t.cpp && ./a.out 
#include <stdio.h>
#include <string.h>

void pbits (const void *pobj, unsigned size)
{
    const unsigned char *pbits = (const unsigned char*)pobj;

    printf ("%u: ", size);

    for (unsigned i = 0; i != size; ++i, ++pbits) {
        for (unsigned j = 0; j != 8; ++j) {
            printf ("%i", 0 != (*pbits & (1 << j)));
        }
        putchar (' ');
    }
    putchar ('\n');
}

int main ()
{
    long double x = 0;
    long double y = 0.;

    pbits (&x, sizeof x);
    pbits (&y, sizeof y);
}
CC: Sun C++ 5.9 Linux_i386 2007/05/03
ir2hf: Sun Compiler Common 12 Linux_i386 2007/05/03
ube: Sun Compiler Common 12 Linux_i386 2007/05/03
GNU ld version 051128 20051128
  Supported emulations:
   elf_x86_64
   elf_i386
   i386linux
/amd/packages/mdx/redhat/compilers/sun/5.9/prod/bin/c++filt: Sun C++ 5.9 Linux_i386 2007/05/03
ccfe: Sun C++ 5.9 Linux_i386 2007/05/03
iropt: Sun Compiler Common 12 Linux_i386 2007/05/03
16: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
11111111 11111101 11111110 00000000 00000000 00000000 
16: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 
{noformat}

Intel C++ 9.1 generates a non-zero pattern in byte 10 for the second case:
{noformat}
$ icc -V t.cpp && ./a.out 
Intel(R) C Compiler for Intel(R) EM64T-based applications, Version 9.1    Build 20070510 Package
ID: l_cc_c_9.1.051
Copyright (C) 1985-2007 Intel Corporation.  All rights reserved.

Edison Design Group C/C++ Front End, version 3.6 (May 10 2007 19:40:33)
Copyright 1988-2005 Edison Design Group, Inc.

GNU ld version 2.15.92.0.2 20040927
16: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 
16: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000010 00000000 00000000 00000000 00000000 00000000 
{noformat}


> [Sun C++ 5.9] 0.char test failed due to different binary representation of "long double
ld1 = 0" and "long double ld2 = 0."
> ---------------------------------------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-862
>                 URL: https://issues.apache.org/jira/browse/STDCXX-862
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: Tests
>    Affects Versions: 4.2.0
>         Environment: Linux
>            Reporter: Farid Zaripov
>            Assignee: Farid Zaripov
>            Priority: Trivial
>             Fix For: 4.2.1
>
>   Original Estimate: 1h
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> {noformat}
> $ cat test.cpp && CC test.cpp -o test && ./test
> #include <cassert>
> #include <cstring>
> int main ()
> {
>     long double ld1 = 0;
>     long double ld2 = 0.;
>     
>     assert (ld1 == ld2);
>     assert (0 == memcmp (&ld1, &ld2, sizeof (ld1)));
>     
>     return 0;
> }
> test: test.cpp:10: Assertion `0 == memcmp (&ld1, &ld2, sizeof (ld1))' failed.
> Aborted
> {noformat}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message