public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/39986]  New: decimal float constant is incorrect when cc1 is a 64-bit binary
@ 2009-04-30 23:59 janis at gcc dot gnu dot org
  2009-05-01 18:58 ` [Bug target/39986] " janis at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: janis at gcc dot gnu dot org @ 2009-04-30 23:59 UTC (permalink / raw)
  To: gcc-bugs

When cc1 for powerpc64-linux is a 32-bit binary, compiling

  _Decimal32 x = 1.2df;

with "-m64 -S" results in:

        .file   "df.c"
        .section        ".toc","aw"
        .section        ".text"
        .globl x
        .section        ".data"
        .align 2
        .type   x, @object
        .size   x, 4
x:
        .long   574619666
        .ident  "GCC: (GNU) 4.5.0 20090430 (experimental) [trunk revision
147009]"

When the same compiler is built to be a 64-bit binary then the result is the
same except for

        .size   x, 4
x:
        .long   2467972673108443136

I normally configure GCC using --with-cpu=default32 and haven't yet checked to
see long the bug has existed; perhaps as long as GCC has supported decimal
float arithmetic.

If check_effective_target_dfprt_nocache fails then the tests in gcc.dg/dfp are
treated as compile-only and the struct-layout-1 tests do not support decimal
float types, and currently there is no test for the correct constant value so
the bug was not detected by running the testsuite.


-- 
           Summary: decimal float constant is incorrect when cc1 is a 64-bit
                    binary
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janis at gcc dot gnu dot org
  GCC host triplet: powerpc64-linux
GCC target triplet: powerpc64-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39986


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/39986] decimal float constant is incorrect when cc1 is a 64-bit binary
  2009-04-30 23:59 [Bug target/39986] New: decimal float constant is incorrect when cc1 is a 64-bit binary janis at gcc dot gnu dot org
@ 2009-05-01 18:58 ` janis at gcc dot gnu dot org
  2009-05-01 19:04 ` janis at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janis at gcc dot gnu dot org @ 2009-05-01 18:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from janis at gcc dot gnu dot org  2009-05-01 18:57 -------
The problem is that in dfp.c, functions encode_decimal* and decode_decimal* use
memcpy from a 32-bit int to a long for 32 bits.  This works fine with -32 where
long is 32 bits, but not for -m64 where long is 32 bits.  I assume that it
magically works fine on little-endian systems like x86_64.

This is not a regression, just a horrible wrong-code bug.

I'm testing a patch.


-- 

janis at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bergner at gcc dot gnu dot
                   |                            |org
         AssignedTo|unassigned at gcc dot gnu   |janis at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-05-01 18:57:58
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39986


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/39986] decimal float constant is incorrect when cc1 is a 64-bit binary
  2009-04-30 23:59 [Bug target/39986] New: decimal float constant is incorrect when cc1 is a 64-bit binary janis at gcc dot gnu dot org
  2009-05-01 18:58 ` [Bug target/39986] " janis at gcc dot gnu dot org
@ 2009-05-01 19:04 ` janis at gcc dot gnu dot org
  2009-05-04 21:24 ` janis at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janis at gcc dot gnu dot org @ 2009-05-01 19:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from janis at gcc dot gnu dot org  2009-05-01 19:03 -------
D'oh, I of course meant that long is 32-bits when GCC is build with default
-m32 and that long is 64-bits when GCC is built with default -m64; the host
size of long, not the target size.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39986


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/39986] decimal float constant is incorrect when cc1 is a 64-bit binary
  2009-04-30 23:59 [Bug target/39986] New: decimal float constant is incorrect when cc1 is a 64-bit binary janis at gcc dot gnu dot org
  2009-05-01 18:58 ` [Bug target/39986] " janis at gcc dot gnu dot org
  2009-05-01 19:04 ` janis at gcc dot gnu dot org
@ 2009-05-04 21:24 ` janis at gcc dot gnu dot org
  2009-05-06 17:02 ` [Bug middle-end/39986] " janis at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janis at gcc dot gnu dot org @ 2009-05-04 21:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from janis at gcc dot gnu dot org  2009-05-04 21:24 -------
On x86_64 with a 64-bit compiler, positive decimal float constants are OK,
negative decimal float constants are wrong for both -m64 (the default) and
-m32.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39986


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/39986] decimal float constant is incorrect when cc1 is a 64-bit binary
  2009-04-30 23:59 [Bug target/39986] New: decimal float constant is incorrect when cc1 is a 64-bit binary janis at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-05-04 21:24 ` janis at gcc dot gnu dot org
@ 2009-05-06 17:02 ` janis at gcc dot gnu dot org
  2009-05-06 17:19 ` janis at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janis at gcc dot gnu dot org @ 2009-05-06 17:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from janis at gcc dot gnu dot org  2009-05-06 17:01 -------
Subject: Bug 39986

Author: janis
Date: Wed May  6 16:59:53 2009
New Revision: 147188

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147188
Log:
        PR middle-end/39986
        * dfp.c (encode_decimal32, decode_decimal32, encode_decimal64,
        decode_decimal64, encode_decimal128, decode_decimal128): Avoid
        32-bit memcpy into long.

        * gcc.dg/dfp/pr39986.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/dfp/pr39986.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dfp.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39986


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/39986] decimal float constant is incorrect when cc1 is a 64-bit binary
  2009-04-30 23:59 [Bug target/39986] New: decimal float constant is incorrect when cc1 is a 64-bit binary janis at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-05-06 17:02 ` [Bug middle-end/39986] " janis at gcc dot gnu dot org
@ 2009-05-06 17:19 ` janis at gcc dot gnu dot org
  2009-05-07 13:15 ` hjl dot tools at gmail dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janis at gcc dot gnu dot org @ 2009-05-06 17:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from janis at gcc dot gnu dot org  2009-05-06 17:18 -------
This was a regression after all, release branches do not have the bug.  I added
the new test case to the 4.4 and 4.3 branches.


-- 

janis at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39986


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/39986] decimal float constant is incorrect when cc1 is a 64-bit binary
  2009-04-30 23:59 [Bug target/39986] New: decimal float constant is incorrect when cc1 is a 64-bit binary janis at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2009-05-06 17:19 ` janis at gcc dot gnu dot org
@ 2009-05-07 13:15 ` hjl dot tools at gmail dot com
  2009-05-07 13:22 ` hjl dot tools at gmail dot com
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-05-07 13:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from hjl dot tools at gmail dot com  2009-05-07 13:15 -------
Only the testcase was checked into 4.4 branch:

http://gcc.gnu.org/ml/gcc-cvs/2009-05/msg00163.html

The dfp.c change is missing on 4.4 branch.


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39986


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/39986] decimal float constant is incorrect when cc1 is a 64-bit binary
  2009-04-30 23:59 [Bug target/39986] New: decimal float constant is incorrect when cc1 is a 64-bit binary janis at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2009-05-07 13:15 ` hjl dot tools at gmail dot com
@ 2009-05-07 13:22 ` hjl dot tools at gmail dot com
  2009-05-07 21:39 ` janis at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-05-07 13:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from hjl dot tools at gmail dot com  2009-05-07 13:22 -------
Gcc 4.4.1 revision  147214 gave:

FAIL: gcc.dg/dfp/pr39986.c scan-assembler .long\t(-1572863965|-1308622825)\n
FAIL: gcc.dg/dfp/pr39986.c scan-assembler .long\t(-1572863965|-1308622825)\n
FAIL: gcc.dg/dfp/pr39986.c scan-assembler .long\t(-1574174720|-1319108608)\n
FAIL: gcc.dg/dfp/pr39986.c scan-assembler .long\t(-1574174720|-1319108608)\n
FAIL: gcc.dg/dfp/pr39986.c scan-assembler .long\t(-1576681472|-1339162624)\n
FAIL: gcc.dg/dfp/pr39986.c scan-assembler .long\t(-1576681472|-1339162624)\n

on Linux/Intel64.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39986


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/39986] decimal float constant is incorrect when cc1 is a 64-bit binary
  2009-04-30 23:59 [Bug target/39986] New: decimal float constant is incorrect when cc1 is a 64-bit binary janis at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2009-05-07 13:22 ` hjl dot tools at gmail dot com
@ 2009-05-07 21:39 ` janis at gcc dot gnu dot org
  2009-05-07 21:43 ` janis at gcc dot gnu dot org
  2009-05-13 20:46 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: janis at gcc dot gnu dot org @ 2009-05-07 21:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from janis at gcc dot gnu dot org  2009-05-07 21:39 -------
Subject: Bug 39986

Author: janis
Date: Thu May  7 21:38:46 2009
New Revision: 147253

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147253
Log:
        PR middle-end/39986
        * dfp.c (encode_decimal32, decode_decimal32, encode_decimal64,
        decode_decimal64, encode_decimal128, decode_decimal128): Avoid
        32-bit memcpy into long.

Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/dfp.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39986


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/39986] decimal float constant is incorrect when cc1 is a 64-bit binary
  2009-04-30 23:59 [Bug target/39986] New: decimal float constant is incorrect when cc1 is a 64-bit binary janis at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2009-05-07 21:39 ` janis at gcc dot gnu dot org
@ 2009-05-07 21:43 ` janis at gcc dot gnu dot org
  2009-05-13 20:46 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: janis at gcc dot gnu dot org @ 2009-05-07 21:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from janis at gcc dot gnu dot org  2009-05-07 21:43 -------
Subject: Bug 39986

Author: janis
Date: Thu May  7 21:43:32 2009
New Revision: 147255

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147255
Log:
        PR middle-end/39986
        * dfp.c (encode_decimal32, decode_decimal32, encode_decimal64,
        decode_decimal64, encode_decimal128, decode_decimal128): Avoid
        32-bit copy into long.

Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/dfp.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39986


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/39986] decimal float constant is incorrect when cc1 is a 64-bit binary
  2009-04-30 23:59 [Bug target/39986] New: decimal float constant is incorrect when cc1 is a 64-bit binary janis at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2009-05-07 21:43 ` janis at gcc dot gnu dot org
@ 2009-05-13 20:46 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-05-13 20:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from pinskia at gcc dot gnu dot org  2009-05-13 20:46 -------
Fixed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39986


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2009-05-13 20:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-30 23:59 [Bug target/39986] New: decimal float constant is incorrect when cc1 is a 64-bit binary janis at gcc dot gnu dot org
2009-05-01 18:58 ` [Bug target/39986] " janis at gcc dot gnu dot org
2009-05-01 19:04 ` janis at gcc dot gnu dot org
2009-05-04 21:24 ` janis at gcc dot gnu dot org
2009-05-06 17:02 ` [Bug middle-end/39986] " janis at gcc dot gnu dot org
2009-05-06 17:19 ` janis at gcc dot gnu dot org
2009-05-07 13:15 ` hjl dot tools at gmail dot com
2009-05-07 13:22 ` hjl dot tools at gmail dot com
2009-05-07 21:39 ` janis at gcc dot gnu dot org
2009-05-07 21:43 ` janis at gcc dot gnu dot org
2009-05-13 20:46 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).