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

Bug#362414: abs() returns a negative number & signed types are undefined on overflow



It seems the problem here is "signed types are undefined on overflow".

abs (2083755264 + abs (abs (79364096) - 256))

Let express in hex on 32bit platform:

abs (0x7c339500 + abs (abs (0x4bb0000) - 0x100))
abs (0x7c339500 + 0x4baff00)
abs (undefined)

Does help to change definition of sum_abs from "int" to "unsigned int" ?

Does help to compile it with "-fwrapv" ?
	http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Code-Gen-Options.html#Code-Gen-Options

Petr





Reply to: