This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libgcc/78067] New: liggcc2 calls count_leading_zero with 0
- From: "bernd.edlinger at hotmail dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 21 Oct 2016 12:49:17 +0000
- Subject: [Bug libgcc/78067] New: liggcc2 calls count_leading_zero with 0
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78067
Bug ID: 78067
Summary: liggcc2 calls count_leading_zero with 0
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgcc
Assignee: unassigned at gcc dot gnu.org
Reporter: bernd.edlinger at hotmail dot de
Target Milestone: ---
in libgcc2.c, __floatdidf, line 1637 I see:
/* If there are no high bits set, fall back to one conversion. */
if ((Wtype)u == u)
return (FSTYPE)(Wtype)u;
/* Otherwise, find the power of two. */
Wtype hi = u >> W_TYPE_SIZE;
if (hi < 0)
hi = -(UWtype) hi;
UWtype count, shift;
count_leading_zeros (count, hi);
If u is 1 << W_TYPE_SIZE - 1
hi will be 0
and count_leading_zeros will be called with 0.
In that case, see longling.h:
5) count_leading_zeros(count, x) counts the number of zero-bits from the
msb to the first nonzero bit in the UWtype X. This is the number of
steps X needs to be shifted left to set the msb. Undefined for X == 0,
unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value.
we should check that COUNT_LEADING_ZEROS_0 is defined and identical
to W_TYPE_SIZE.
like this:
UWtype count, shift;
#if defined (COUNT_LEADING_ZEROS_0) && COUNT_LEADING_ZEROS_0 == W_TYPE_SIZE
if (hi == 0)
count = W_TYPE_SIZE;
else
#endif
count_leading_zeros (count, hi);