[LLVMbugs] [Bug 13615] APInt::udivrem says 1/1 == -1
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Aug 18 02:30:23 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13615
Benjamin Kramer <benny.kra at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |benny.kra at gmail.com
Resolution| |INVALID
--- Comment #1 from Benjamin Kramer <benny.kra at gmail.com> 2012-08-18 04:30:23 CDT ---
This is an artifact of the default APInt constructor. It creates an APInt with
bit width 1, and with that width 1 is equal to -1.
The right usage of udivrem is:
APInt a(32, 1), b(32, 1), c(32, 0), d(32, 0);
APInt::udivrem(a, b, c, d);
dbgs() << "dividing " << a << " by " << b << " yields " << c << " rem " << d <<
"\n";
and it prints:
dividing 1 by 1 yields 1 rem 0
I agree that it is very easy to misuse this API but I'm not sure how to fix it.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list