[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#452108: gcc-4.2: Incorrect results with abs()



On Tue, Nov 20, 2007 at 03:09:17PM +0100, Frans Pop wrote:
> The following test program will result in "OMG,-10==10 in linux!" when
> compiled with both gcc-4.1 and gcc-4.2.

Further information:

| int i = 2;
| int a = -10 * abs (i - 1);
| int b = 10 * abs (i - 1);
compiles to (original tree)
| int i = 2;
| int a = ABS_EXPR <i * -10 + 10>;
| int b = ABS_EXPR <i * 10 + -10>;

| int i = 2;
| int a = -10 * abs (i);
| int b = 10 * abs (i);
compiles to
| int i = 2;
| int a = ABS_EXPR <i> * -10;
| int b = ABS_EXPR <i> * 10;

Bastian

-- 
There is a multi-legged creature crawling on your shoulder.
		-- Spock, "A Taste of Armageddon", stardate 3193.9

Attachment: signature.asc
Description: Digital signature


Reply to: