This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/36300] Incorrect type used for inlined expression
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 May 2008 10:12:26 -0000
- Subject: [Bug middle-end/36300] Incorrect type used for inlined expression
- References: <bug-36300-16214@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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