public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/47473] New: Incorrect computation with complex numbers when using -std=c99
@ 2011-01-26 11:43 abelk at live dot com
  2011-01-26 11:54 ` [Bug target/47473] [4.5/4.6 Regression] " rguenth at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: abelk at live dot com @ 2011-01-26 11:43 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Incorrect computation with complex numbers when using
                    -std=c99
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: abelk@live.com


Created attachment 23131
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23131
complexbug3.i

This is a report about an issue encountered in MinGW GCC. The maintainers of
the MinGW project suggested to report it here.

The command line that triggers the bug is:

gcc -v -save-temps -Wall -std=c99 complexbug3.c -o complexbug3.exe

The option -std=c99 triggers the bug.

The resultant output is:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/program
files/mingw/bin/../libexec/gcc/mingw32/4.5.0/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.0/configure
--enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions
--with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry
--enable-libstdcxx-debug --enable-version-specific-runtime-libs
--disable-werror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-std=c99' '-o'
'complexbug3.exe' '-mtune=i386' '-march=i386'
 c:/program files/mingw/bin/../libexec/gcc/mingw32/4.5.0/cc1.exe -E -quiet -v
-iprefix c:\program files\mingw\bin\../lib/gcc/mingw32/4.5.0/ complexbug3.c
-mtune=i386 -march=i386 -std=c99 -Wall -fpch-preprocess -o complexbug3.i
ignoring nonexistent directory "c:\program
files\mingw\bin\../lib/gcc/mingw32/4.5.0/../../../../mingw32/include"
ignoring nonexistent directory "c:/mingw/include"
ignoring nonexistent directory "/mingw/include"
ignoring duplicate directory "c:/program
files/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.0/include"
ignoring duplicate directory "c:/program
files/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.0/include-fixed"
ignoring nonexistent directory "c:/program
files/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.0/../../../../mingw32/include"
ignoring nonexistent directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 c:\program files\mingw\bin\../lib/gcc/mingw32/4.5.0/../../../../include
 c:\program files\mingw\bin\../lib/gcc/mingw32/4.5.0/include
 c:\program files\mingw\bin\../lib/gcc/mingw32/4.5.0/include-fixed
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-std=c99' '-o'
'complexbug3.exe' '-mtune=i386' '-march=i386'
 c:/program files/mingw/bin/../libexec/gcc/mingw32/4.5.0/cc1.exe -fpreprocessed
complexbug3.i -quiet -dumpbase complexbug3.c -mtune=i386 -march=i386 -auxbase
complexbug3 -Wall -std=c99 -version -o complexbug3.s
GNU C (GCC) version 4.5.0 (mingw32)
    compiled by GNU C version 4.5.0, GMP version 5.0.1, MPFR version 2.4.1, MPC
version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C (GCC) version 4.5.0 (mingw32)
    compiled by GNU C version 4.5.0, GMP version 5.0.1, MPFR version 2.4.1, MPC
version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 6773400e8bc9df4b012089071ac4c86b
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-std=c99' '-o'
'complexbug3.exe' '-mtune=i386' '-march=i386'
 c:/program
files/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/as.exe -o
complexbug3.o complexbug3.s
COMPILER_PATH=c:/program
files/mingw/bin/../libexec/gcc/mingw32/4.5.0/;c:/program
files/mingw/bin/../libexec/gcc/;c:/program
files/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/program files/mingw/bin/../lib/gcc/mingw32/4.5.0/;c:/program
files/mingw/bin/../lib/gcc/;c:/program
files/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/lib/;c:/program
files/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-std=c99' '-o'
'complexbug3.exe' '-mtune=i386' '-march=i386'
 c:/program files/mingw/bin/../libexec/gcc/mingw32/4.5.0/collect2.exe -Bdynamic
-o complexbug3.exe c:/program
files/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../crt2.o c:/program
files/mingw/bin/../lib/gcc/mingw32/4.5.0/crtbegin.o -Lc:/program
files/mingw/bin/../lib/gcc/mingw32/4.5.0 -Lc:/program
files/mingw/bin/../lib/gcc -Lc:/program
files/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/lib -Lc:/program
files/mingw/bin/../lib/gcc/mingw32/4.5.0/../../.. complexbug3.o -lmingw32
-lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32
-lshell32 -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt c:/program
files/mingw/bin/../lib/gcc/mingw32/4.5.0/crtend.o


The result of executing complexbug3.exe is mathematically incorrect:
(0.2 - I*0.3)*(0.3 - I*0.9) = (0.06, -0.09)


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

* [Bug target/47473] [4.5/4.6 Regression] Incorrect computation with complex numbers when using -std=c99
  2011-01-26 11:43 [Bug c/47473] New: Incorrect computation with complex numbers when using -std=c99 abelk at live dot com
@ 2011-01-26 11:54 ` rguenth at gcc dot gnu.org
  2011-01-26 14:13 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-01-26 11:54 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |i?86-*-*
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |4.4.4
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2011.01.26 11:26:29
          Component|c                           |target
     Ever Confirmed|0                           |1
            Summary|Incorrect computation with  |[4.5/4.6 Regression]
                   |complex numbers when using  |Incorrect computation with
                   |-std=c99                    |complex numbers when using
                   |                            |-std=c99
   Target Milestone|---                         |4.5.3
      Known to fail|                            |4.5.0, 4.5.2, 4.6.0

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-26 11:26:29 UTC ---
Confirmed on i?86-linux.  Seems to be a problem with libgcc __mulxc3, linking
with the libgcc from 4.4 makes it work for the failing releases.


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

* [Bug target/47473] [4.5/4.6 Regression] Incorrect computation with complex numbers when using -std=c99
  2011-01-26 11:43 [Bug c/47473] New: Incorrect computation with complex numbers when using -std=c99 abelk at live dot com
  2011-01-26 11:54 ` [Bug target/47473] [4.5/4.6 Regression] " rguenth at gcc dot gnu.org
@ 2011-01-26 14:13 ` jakub at gcc dot gnu.org
  2011-01-26 15:34 ` [Bug c/47473] " jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-01-26 14:13 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-01-26 13:42:50 UTC ---
Unincluded testcase:
int
main (void)
{
 long double _Complex w = 0.2L - 0.3iL;
  w = w * (0.3L - (0.0F + 1.0iF) * 0.9L);
  __builtin_printf("(0.2 - I*0.3)*(0.3 - I*0.9) = (%g, %g)\n", (double)
__real__ w, (double) __imag__ w);
  return 0;
}

On x86_64-linux the results look correct.
Using
w = w * (0.3L - 0.9iL);
instead works too.  And the results I get don't depend on libgcc version used
(4.4 behaves like 4.6).


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

* [Bug c/47473] [4.5/4.6 Regression] Incorrect computation with complex numbers when using -std=c99
  2011-01-26 11:43 [Bug c/47473] New: Incorrect computation with complex numbers when using -std=c99 abelk at live dot com
  2011-01-26 11:54 ` [Bug target/47473] [4.5/4.6 Regression] " rguenth at gcc dot gnu.org
  2011-01-26 14:13 ` jakub at gcc dot gnu.org
@ 2011-01-26 15:34 ` jakub at gcc dot gnu.org
  2011-01-26 15:39 ` hjl.tools at gmail dot com
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-01-26 15:34 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
          Component|target                      |c
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-01-26 15:10:07 UTC ---
Mine.


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

* [Bug c/47473] [4.5/4.6 Regression] Incorrect computation with complex numbers when using -std=c99
  2011-01-26 11:43 [Bug c/47473] New: Incorrect computation with complex numbers when using -std=c99 abelk at live dot com
                   ` (2 preceding siblings ...)
  2011-01-26 15:34 ` [Bug c/47473] " jakub at gcc dot gnu.org
@ 2011-01-26 15:39 ` hjl.tools at gmail dot com
  2011-01-26 16:14 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: hjl.tools at gmail dot com @ 2011-01-26 15:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> 2011-01-26 15:14:10 UTC ---
It is caused by revision 147281:

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


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

* [Bug c/47473] [4.5/4.6 Regression] Incorrect computation with complex numbers when using -std=c99
  2011-01-26 11:43 [Bug c/47473] New: Incorrect computation with complex numbers when using -std=c99 abelk at live dot com
                   ` (3 preceding siblings ...)
  2011-01-26 15:39 ` hjl.tools at gmail dot com
@ 2011-01-26 16:14 ` jakub at gcc dot gnu.org
  2011-01-26 20:45 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-01-26 16:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-01-26 15:19:56 UTC ---
Created attachment 23132
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23132
gcc46-pr47473.patch

Untested fix.


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

* [Bug c/47473] [4.5/4.6 Regression] Incorrect computation with complex numbers when using -std=c99
  2011-01-26 11:43 [Bug c/47473] New: Incorrect computation with complex numbers when using -std=c99 abelk at live dot com
                   ` (4 preceding siblings ...)
  2011-01-26 16:14 ` jakub at gcc dot gnu.org
@ 2011-01-26 20:45 ` jakub at gcc dot gnu.org
  2011-01-26 21:12 ` [Bug c/47473] [4.5 " jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-01-26 20:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-01-26 20:07:02 UTC ---
Author: jakub
Date: Wed Jan 26 20:06:57 2011
New Revision: 169299

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169299
Log:
    PR c/47473
    * c-lex.c (interpret_float): If CPP_N_IMAGINARY, ensure
    EXCESS_PRECISION_EXPR is created with COMPLEX_TYPE instead of
    REAL_TYPE.

    * gcc.dg/torture/pr47473.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr47473.c
Modified:
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-lex.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c/47473] [4.5 Regression] Incorrect computation with complex numbers when using -std=c99
  2011-01-26 11:43 [Bug c/47473] New: Incorrect computation with complex numbers when using -std=c99 abelk at live dot com
                   ` (5 preceding siblings ...)
  2011-01-26 20:45 ` jakub at gcc dot gnu.org
@ 2011-01-26 21:12 ` jakub at gcc dot gnu.org
  2011-02-02 18:07 ` dnovillo at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-01-26 21:12 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.6.0
            Summary|[4.5/4.6 Regression]        |[4.5 Regression] Incorrect
                   |Incorrect computation with  |computation with complex
                   |complex numbers when using  |numbers when using -std=c99
                   |-std=c99                    |
      Known to fail|4.6.0                       |

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-01-26 20:08:40 UTC ---
Fixed on the trunk so far.


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

* [Bug c/47473] [4.5 Regression] Incorrect computation with complex numbers when using -std=c99
  2011-01-26 11:43 [Bug c/47473] New: Incorrect computation with complex numbers when using -std=c99 abelk at live dot com
                   ` (6 preceding siblings ...)
  2011-01-26 21:12 ` [Bug c/47473] [4.5 " jakub at gcc dot gnu.org
@ 2011-02-02 18:07 ` dnovillo at gcc dot gnu.org
  2011-03-08 13:26 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dnovillo at gcc dot gnu.org @ 2011-02-02 18:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Diego Novillo <dnovillo at gcc dot gnu.org> 2011-02-02 17:53:56 UTC ---
Author: dnovillo
Date: Wed Feb  2 17:53:51 2011
New Revision: 169624

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169624
Log:
    PR c/47473
    * c-lex.c (interpret_float): If CPP_N_IMAGINARY, ensure
    EXCESS_PRECISION_EXPR is created with COMPLEX_TYPE instead of
    REAL_TYPE.

    * gcc.dg/torture/pr47473.c: New test.

Added:
    branches/google/integration/gcc/testsuite/gcc.dg/torture/pr47473.c
Modified:
    branches/google/integration/gcc/c-family/ChangeLog
    branches/google/integration/gcc/c-family/c-lex.c
    branches/google/integration/gcc/testsuite/ChangeLog


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

* [Bug c/47473] [4.5 Regression] Incorrect computation with complex numbers when using -std=c99
  2011-01-26 11:43 [Bug c/47473] New: Incorrect computation with complex numbers when using -std=c99 abelk at live dot com
                   ` (7 preceding siblings ...)
  2011-02-02 18:07 ` dnovillo at gcc dot gnu.org
@ 2011-03-08 13:26 ` rguenth at gcc dot gnu.org
  2011-04-07 18:24 ` jakub at gcc dot gnu.org
  2011-04-07 18:40 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-03-08 13:26 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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

* [Bug c/47473] [4.5 Regression] Incorrect computation with complex numbers when using -std=c99
  2011-01-26 11:43 [Bug c/47473] New: Incorrect computation with complex numbers when using -std=c99 abelk at live dot com
                   ` (8 preceding siblings ...)
  2011-03-08 13:26 ` rguenth at gcc dot gnu.org
@ 2011-04-07 18:24 ` jakub at gcc dot gnu.org
  2011-04-07 18:40 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-04-07 18:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-04-07 18:24:45 UTC ---
Author: jakub
Date: Thu Apr  7 18:24:43 2011
New Revision: 172113

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172113
Log:
    Backported from mainline
    2011-01-26  Jakub Jelinek  <jakub@redhat.com>

    PR c/47473
    * c-lex.c (interpret_float): If CPP_N_IMAGINARY, ensure
    EXCESS_PRECISION_EXPR is created with COMPLEX_TYPE instead of
    REAL_TYPE.

    * gcc.dg/torture/pr47473.c: New test.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/torture/pr47473.c
Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/c-lex.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


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

* [Bug c/47473] [4.5 Regression] Incorrect computation with complex numbers when using -std=c99
  2011-01-26 11:43 [Bug c/47473] New: Incorrect computation with complex numbers when using -std=c99 abelk at live dot com
                   ` (9 preceding siblings ...)
  2011-04-07 18:24 ` jakub at gcc dot gnu.org
@ 2011-04-07 18:40 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-04-07 18:40 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-04-07 18:40:04 UTC ---
Fixed.


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

end of thread, other threads:[~2011-04-07 18:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-26 11:43 [Bug c/47473] New: Incorrect computation with complex numbers when using -std=c99 abelk at live dot com
2011-01-26 11:54 ` [Bug target/47473] [4.5/4.6 Regression] " rguenth at gcc dot gnu.org
2011-01-26 14:13 ` jakub at gcc dot gnu.org
2011-01-26 15:34 ` [Bug c/47473] " jakub at gcc dot gnu.org
2011-01-26 15:39 ` hjl.tools at gmail dot com
2011-01-26 16:14 ` jakub at gcc dot gnu.org
2011-01-26 20:45 ` jakub at gcc dot gnu.org
2011-01-26 21:12 ` [Bug c/47473] [4.5 " jakub at gcc dot gnu.org
2011-02-02 18:07 ` dnovillo at gcc dot gnu.org
2011-03-08 13:26 ` rguenth at gcc dot gnu.org
2011-04-07 18:24 ` jakub at gcc dot gnu.org
2011-04-07 18:40 ` jakub at gcc dot gnu.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).