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 middle-end/36300] Incorrect type used for inlined expression



------- Comment #5 from rguenth at gcc dot gnu dot org  2008-05-26 10:12 -------
We enter extract_muldiv with

(long long int) (((int) ((unsigned int) U1 * 3) + 2) * ((int) ((unsigned int)
U1 * 3) + 2))

and 3 and go down the widening route with long long and then the same operand
of MULT_EXPR route applying a long long widened multiplication to

(int) ((unsigned int) U1 * 3) + 2

and 3 resulting in

(long long int) (int) ((unsigned int) U1 * 3) * 3 + 6


I would say this bug is invalid as it assumes we need to preserve truncations
of overflowed computations on signed integers, but with -fwrapv the same
error happens.

Testcase that works:

extern void abort (void);

#define VALUE (unsigned int)((int)((long long)U1 * (long long)3) + 2)

int main(void)
{
  int U1;
  long long Y, Y2;
  unsigned int t;

  U1 = -2147483647-1;

  Y = ((long long)(int)(VALUE * VALUE) * 3);

  t = VALUE;
  Y2 = ((long long)(int)(t * t) * 3);

  if (Y != Y2)
    abort ();
  return 0;
}


-- 


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


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