This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug bootstrap/49914] call to abs(long long) in gcc/fold-const.c
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 2 Aug 2011 12:32:59 +0000
- Subject: [Bug bootstrap/49914] call to abs(long long) in gcc/fold-const.c
- Auto-submitted: auto-generated
- References: <bug-49914-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
--- Comment #9 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-08-02 12:32:24 UTC ---
On Tue, 2 Aug 2011, rguenther at suse dot de wrote:
> well, I don't think we want the assert in abs_hwi as it stands now.
> Either we can handle this case in the callers or we should just do
> what we can - exploit the undefined behavior and return INT_MIN for
> INT_MIN.
If a caller is prepared to get a negative value back from abs_hwi, then an
abs_hwi_wrap version would seem appropriate for such a caller (or a
version that returns unsigned HOST_WIDE_INT, if the callers are written to
work with unsigned values). If a caller expects the result to be positive
and always the absolute value (but of a signed type), it's a bug in the
caller to pass the least HOST_WIDE_INT value, and the assert serves to
detect such a bug in the caller.