public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/22360] New: upper_bound_in_type and lower_bound_in_type are buggy
@ 2005-07-08  2:06 kazu at gcc dot gnu dot org
  2005-07-08 14:17 ` [Bug tree-optimization/22360] " kazu at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: kazu at gcc dot gnu dot org @ 2005-07-08  2:06 UTC (permalink / raw)
  To: gcc-bugs

Consider tree.c:upper_bound_in_type

Suppose that outer is ulong64 and that inner is int32.  Then the function
returns 2^32-1, which is wrong.  Since we are widening a signed value, we need
to use a sign extension.  The largest value after casting to ulong64 is actually
2^64-1, which occurs when sign-extending (int32) -1.

Consider tree.c:lower_bound_in_type

Suppose that outer is int32 and that inner is ulong64.  Then the function
returns 0, which is wrong.  Since we are narrowing, the result of a cast
can take all values of int32.  The smallest value after casting to int32 is
-2^31, which occurs when we narrow 2^31.

These functions are used from fold-const.c, but I was unable to come up with a
testcase that exposed this bug.

This bug showed up as a latent bug while I was working on PR20139.

I've got a patch to fix this.

-- 
           Summary: upper_bound_in_type and lower_bound_in_type are buggy
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: kazu at gcc dot gnu dot org
        ReportedBy: kazu at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
OtherBugsDependingO 20139
             nThis:


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


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

* [Bug tree-optimization/22360] upper_bound_in_type and lower_bound_in_type are buggy
  2005-07-08  2:06 [Bug tree-optimization/22360] New: upper_bound_in_type and lower_bound_in_type are buggy kazu at gcc dot gnu dot org
@ 2005-07-08 14:17 ` kazu at gcc dot gnu dot org
  2005-07-08 15:06 ` [Bug tree-optimization/22360] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: kazu at gcc dot gnu dot org @ 2005-07-08 14:17 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2005-
                   |                            |07/msg00566.html


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


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

* [Bug tree-optimization/22360] [4.0/4.1 Regression] upper_bound_in_type and lower_bound_in_type are buggy
  2005-07-08  2:06 [Bug tree-optimization/22360] New: upper_bound_in_type and lower_bound_in_type are buggy kazu at gcc dot gnu dot org
  2005-07-08 14:17 ` [Bug tree-optimization/22360] " kazu at gcc dot gnu dot org
@ 2005-07-08 15:06 ` pinskia at gcc dot gnu dot org
  2005-07-08 15:07 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-08 15:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-08 15:06 -------
Confirmed, this is a latent bug in 4.0.0.  The code was not in 3.4.0 so this is 4.0.0 regression.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |patch, wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2005-07-08 15:06:22
               date|                            |
            Summary|upper_bound_in_type and     |[4.0/4.1 Regression]
                   |lower_bound_in_type are     |upper_bound_in_type and
                   |buggy                       |lower_bound_in_type are
                   |                            |buggy
   Target Milestone|---                         |4.0.2
            Version|unknown                     |4.1.0


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


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

* [Bug tree-optimization/22360] [4.0/4.1 Regression] upper_bound_in_type and lower_bound_in_type are buggy
  2005-07-08  2:06 [Bug tree-optimization/22360] New: upper_bound_in_type and lower_bound_in_type are buggy kazu at gcc dot gnu dot org
  2005-07-08 14:17 ` [Bug tree-optimization/22360] " kazu at gcc dot gnu dot org
  2005-07-08 15:06 ` [Bug tree-optimization/22360] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
@ 2005-07-08 15:07 ` pinskia at gcc dot gnu dot org
  2005-07-08 18:49 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-08 15:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-08 15:07 -------
This also blocks the tree combiner even though I don't see the regression on ppc-darwin.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |15459
              nThis|                            |


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


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

* [Bug tree-optimization/22360] [4.0/4.1 Regression] upper_bound_in_type and lower_bound_in_type are buggy
  2005-07-08  2:06 [Bug tree-optimization/22360] New: upper_bound_in_type and lower_bound_in_type are buggy kazu at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-07-08 15:07 ` pinskia at gcc dot gnu dot org
@ 2005-07-08 18:49 ` cvs-commit at gcc dot gnu dot org
  2005-07-08 18:50 ` kazu at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-07-08 18:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-07-08 18:49 -------
Subject: Bug 22360

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	kazu@gcc.gnu.org	2005-07-08 18:49:07

Modified files:
	gcc            : ChangeLog tree.c 

Log message:
	PR tree-optimization/22360
	* tree.c (upper_bound_in_type): Fix calculations for casting
	to a non-wider signed type and casting a signed value to a
	wider unsigned type.
	(lower_bound_in_type): Fix calculations for casting to a
	non-wider signed type.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9384&r2=2.9385
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&r1=1.494&r2=1.495



-- 


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


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

* [Bug tree-optimization/22360] [4.0/4.1 Regression] upper_bound_in_type and lower_bound_in_type are buggy
  2005-07-08  2:06 [Bug tree-optimization/22360] New: upper_bound_in_type and lower_bound_in_type are buggy kazu at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2005-07-08 18:49 ` cvs-commit at gcc dot gnu dot org
@ 2005-07-08 18:50 ` kazu at gcc dot gnu dot org
  2005-07-09 15:59 ` [Bug tree-optimization/22360] [4.0 " pinskia at gcc dot gnu dot org
  2005-09-27 16:25 ` mmitchel at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: kazu at gcc dot gnu dot org @ 2005-07-08 18:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at gcc dot gnu dot org  2005-07-08 18:49 -------
Just checked in a fix.


-- 


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


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

* [Bug tree-optimization/22360] [4.0 Regression] upper_bound_in_type and lower_bound_in_type are buggy
  2005-07-08  2:06 [Bug tree-optimization/22360] New: upper_bound_in_type and lower_bound_in_type are buggy kazu at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2005-07-08 18:50 ` kazu at gcc dot gnu dot org
@ 2005-07-09 15:59 ` pinskia at gcc dot gnu dot org
  2005-09-27 16:25 ` mmitchel at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-09 15:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-09 15:57 -------
Fixed at least on the mainline.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.0/4.1 Regression]        |[4.0 Regression]
                   |upper_bound_in_type and     |upper_bound_in_type and
                   |lower_bound_in_type are     |lower_bound_in_type are
                   |buggy                       |buggy


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


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

* [Bug tree-optimization/22360] [4.0 Regression] upper_bound_in_type and lower_bound_in_type are buggy
  2005-07-08  2:06 [Bug tree-optimization/22360] New: upper_bound_in_type and lower_bound_in_type are buggy kazu at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2005-07-09 15:59 ` [Bug tree-optimization/22360] [4.0 " pinskia at gcc dot gnu dot org
@ 2005-09-27 16:25 ` mmitchel at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-09-27 16:25 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.2                       |4.0.3


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


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

end of thread, other threads:[~2005-09-27 16:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-08  2:06 [Bug tree-optimization/22360] New: upper_bound_in_type and lower_bound_in_type are buggy kazu at gcc dot gnu dot org
2005-07-08 14:17 ` [Bug tree-optimization/22360] " kazu at gcc dot gnu dot org
2005-07-08 15:06 ` [Bug tree-optimization/22360] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-07-08 15:07 ` pinskia at gcc dot gnu dot org
2005-07-08 18:49 ` cvs-commit at gcc dot gnu dot org
2005-07-08 18:50 ` kazu at gcc dot gnu dot org
2005-07-09 15:59 ` [Bug tree-optimization/22360] [4.0 " pinskia at gcc dot gnu dot org
2005-09-27 16:25 ` mmitchel 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).