public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/36137]  New: gcc can't do math
@ 2008-05-05 14:17 otte at gnome dot org
  2008-05-05 14:18 ` [Bug c/36137] " otte at gnome dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: otte at gnome dot org @ 2008-05-05 14:17 UTC (permalink / raw)
  To: gcc-bugs

The attached program prints (unsigned) -1 as opposed to 1.
This doesn't happen if intermediate variables are used somewhere in the
process.

I tested gcc 3.4, 4.2.3 (on both x86 and x86-64) with -O0 and -O2, all ended up
with -1.
suncc printed 1.


-- 
           Summary: gcc can't do math
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: otte at gnome dot org
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


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


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

* [Bug c/36137] gcc can't do math
  2008-05-05 14:17 [Bug c/36137] New: gcc can't do math otte at gnome dot org
@ 2008-05-05 14:18 ` otte at gnome dot org
  2008-05-05 19:10 ` [Bug middle-end/36137] " tromey at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: otte at gnome dot org @ 2008-05-05 14:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from otte at gnome dot org  2008-05-05 14:17 -------
Created an attachment (id=15581)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15581&action=view)
testcase


-- 


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


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

* [Bug middle-end/36137] gcc can't do math
  2008-05-05 14:17 [Bug c/36137] New: gcc can't do math otte at gnome dot org
  2008-05-05 14:18 ` [Bug c/36137] " otte at gnome dot org
@ 2008-05-05 19:10 ` tromey at gcc dot gnu dot org
  2008-05-05 22:28 ` tromey at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at gcc dot gnu dot org @ 2008-05-05 19:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from tromey at gcc dot gnu dot org  2008-05-05 19:10 -------
test.c.t02.original says:

  u = MAX_EXPR <(unsigned int) i, 1>;

... but this is wrong.


-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-05-05 19:10:16
               date|                            |


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


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

* [Bug middle-end/36137] gcc can't do math
  2008-05-05 14:17 [Bug c/36137] New: gcc can't do math otte at gnome dot org
  2008-05-05 14:18 ` [Bug c/36137] " otte at gnome dot org
  2008-05-05 19:10 ` [Bug middle-end/36137] " tromey at gcc dot gnu dot org
@ 2008-05-05 22:28 ` tromey at gcc dot gnu dot org
  2008-05-06 10:51 ` jakub at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at gcc dot gnu dot org @ 2008-05-05 22:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from tromey at gcc dot gnu dot org  2008-05-05 22:27 -------
fold_binary sees both MAX_EXPRs and reassociates.
(I think this is why it works with intermediate variables.)

Then associate_trees creates a new MAX_EXPR, converting each
argument to unsigned:

  return fold_build2 (code, type, fold_convert (type, t1),
                      fold_convert (type, t2));

So, this is where the error enters.
I'm not sure where this is best fixed though.


-- 


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


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

* [Bug middle-end/36137] gcc can't do math
  2008-05-05 14:17 [Bug c/36137] New: gcc can't do math otte at gnome dot org
                   ` (2 preceding siblings ...)
  2008-05-05 22:28 ` tromey at gcc dot gnu dot org
@ 2008-05-06 10:51 ` jakub at gcc dot gnu dot org
  2008-05-07  7:42 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-05-06 10:51 UTC (permalink / raw)
  To: gcc-bugs



-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
           Keywords|                            |wrong-code
   Last reconfirmed|2008-05-05 19:10:16         |2008-05-06 10:50:49
               date|                            |


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


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

* [Bug middle-end/36137] gcc can't do math
  2008-05-05 14:17 [Bug c/36137] New: gcc can't do math otte at gnome dot org
                   ` (3 preceding siblings ...)
  2008-05-06 10:51 ` jakub at gcc dot gnu dot org
@ 2008-05-07  7:42 ` jakub at gcc dot gnu dot org
  2008-05-07  8:00 ` jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-05-07  7:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2008-05-07 07:41 -------
Subject: Bug 36137

Author: jakub
Date: Wed May  7 07:40:01 2008
New Revision: 135028

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135028
Log:
        PR middle-end/36137
        * fold-const.c (fold_binary): Use STRIP_SIGN_NOPS instead of
        STRIP_NOPS on arguments even for MIN_EXPR and MAX_EXPR.

        * gcc.c-torture/execute/20080506-1.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/20080506-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/36137] gcc can't do math
  2008-05-05 14:17 [Bug c/36137] New: gcc can't do math otte at gnome dot org
                   ` (4 preceding siblings ...)
  2008-05-07  7:42 ` jakub at gcc dot gnu dot org
@ 2008-05-07  8:00 ` jakub at gcc dot gnu dot org
  2008-05-07  8:07 ` jakub at gcc dot gnu dot org
  2008-05-07 19:32 ` rguenth at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-05-07  8:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jakub at gcc dot gnu dot org  2008-05-07 07:59 -------
Subject: Bug 36137

Author: jakub
Date: Wed May  7 07:58:33 2008
New Revision: 135031

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135031
Log:
        PR middle-end/36137
        * fold-const.c (fold_binary): Use STRIP_SIGN_NOPS instead of
        STRIP_NOPS on arguments even for MIN_EXPR and MAX_EXPR.

        * gcc.c-torture/execute/20080506-1.c: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/execute/20080506-1.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/fold-const.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/36137] gcc can't do math
  2008-05-05 14:17 [Bug c/36137] New: gcc can't do math otte at gnome dot org
                   ` (5 preceding siblings ...)
  2008-05-07  8:00 ` jakub at gcc dot gnu dot org
@ 2008-05-07  8:07 ` jakub at gcc dot gnu dot org
  2008-05-07 19:32 ` rguenth at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-05-07  8:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jakub at gcc dot gnu dot org  2008-05-07 08:06 -------
Fixed in 4.3 and on the trunk.


-- 

jakub at gcc dot gnu dot org changed:

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


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


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

* [Bug middle-end/36137] gcc can't do math
  2008-05-05 14:17 [Bug c/36137] New: gcc can't do math otte at gnome dot org
                   ` (6 preceding siblings ...)
  2008-05-07  8:07 ` jakub at gcc dot gnu dot org
@ 2008-05-07 19:32 ` rguenth at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-05-07 19:32 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.2.3
      Known to work|                            |4.3.1
   Target Milestone|---                         |4.3.1


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


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

end of thread, other threads:[~2008-05-07 19:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-05 14:17 [Bug c/36137] New: gcc can't do math otte at gnome dot org
2008-05-05 14:18 ` [Bug c/36137] " otte at gnome dot org
2008-05-05 19:10 ` [Bug middle-end/36137] " tromey at gcc dot gnu dot org
2008-05-05 22:28 ` tromey at gcc dot gnu dot org
2008-05-06 10:51 ` jakub at gcc dot gnu dot org
2008-05-07  7:42 ` jakub at gcc dot gnu dot org
2008-05-07  8:00 ` jakub at gcc dot gnu dot org
2008-05-07  8:07 ` jakub at gcc dot gnu dot org
2008-05-07 19:32 ` rguenth 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).