This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/16790] [3.3/3.4/3.5 regression] Integer down cast ignored in larger expression


------- Additional Comments From bangerth at dealii dot org  2004-07-27 23:12 -------
Confirmed. A regression in 3.3/3.4/mainline against 2.95. Here's  
a reduced testcase: 
---------------- 
void abort (); 
 
static void compute(unsigned int u1) 
{ 
  unsigned char same_result; 
 
  signed short y_final_1; 
  signed short y_middle; 
  signed short y_final_2; 
 
  y_final_1 = (signed short)( (signed short)(u1 << 1) * 3 >> 1); 
  y_middle  =                 (signed short)(u1 << 1); 
  y_final_2 = (signed short)( y_middle * 3 >> 1); 
 
  if (y_final_1 != y_final_2) 
    abort (); 
} 
 
main() 
{ 
  compute(0x4000U); 
} 
----------------------------- 
 
Note that (0x4000<<1) is just the corner case when casted to signed int, 
since it has only the sign bit set, none of the other bits are set. We 
seem to get this wrong somehow. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
      Known to fail|                            |3.2.3 3.3.3 3.4.0 3.5.0
      Known to work|                            |2.95
   Last reconfirmed|0000-00-00 00:00:00         |2004-07-27 23:12:21
               date|                            |
            Summary|Integer down cast ignored in|[3.3/3.4/3.5 regression]
                   |larger expression           |Integer down cast ignored in
                   |                            |larger expression
   Target Milestone|---                         |3.3.5


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]