This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/82584] New: div by zero in random distribution


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82584

            Bug ID: 82584
           Summary: div by zero in random distribution
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nathan at gcc dot gnu.org
  Target Milestone: ---

Created attachment 42384
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42384&action=edit
compile with -fsanitize=float-divide-by-zero

the attached program, when using ubsan generates:
/data/users/nathans/trunk/obj/x86_64/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/random.tcc:88:25:
runtime error: division by zero

line 88 is:
          *__result = *__first / __factor;

and both *__first and __factor are zero.  We end up at:
   0x000000000040314c <+171>:   movsd  -0x40(%rbp),%xmm0
   0x0000000000403151 <+176>:   divsd  -0x38(%rbp),%xmm0
   0x0000000000403156 <+181>:   movsd  %xmm0,-0x38(%rbp)
where both the operands are zero

Not sure if this is user error in that feeding vector<int>{0,0} to
discrete_distribution is valid or not.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]