Boost logo

Boost Users :

Subject: Re: [Boost-users] 1.36.0 boost/random/uniform_01 Infinite[?] Loop
From: Dave Steenburgh (dave.steenburgh_at_[hidden])
Date: 2008-10-16 16:38:24


> Could you show the generated assembler for this as well?

I should definitely learn a better method for getting this info, and having
unmangled names would be nice, too.

This boost code:

  result_type operator()() {
    for (;;) {
      result_type result = result_type(_rng() - (_rng.min)()) * _factor;
      if (result < result_type(1))
        return result;
    }
  }

Is compiled to this:

__ZN5boost10uniform_01INS_6random6detail19pass_through_engineIRNS1_19linear_congruentialIlLl48271ELl0ELl2147483647ELl399268537EEEEEdEclEv:
.stabn
68,0,57,LM909-__ZN5boost10uniform_01INS_6random6detail19pass_through_engineIRNS1_19linear_congruentialIlLl48271ELl0ELl2147483647ELl399268537EEEEEdEclEv
LM909:
pushl %ebp #
 movl %esp, %ebp #,
pushl %ebx #
 subl $20, %esp #,
L840:
LBB361:
LBB362:
LBB363:
LBB364:
LBB365:
.stabn
68,0,59,LM910-__ZN5boost10uniform_01INS_6random6detail19pass_through_engineIRNS1_19linear_congruentialIlLl48271ELl0ELl2147483647ELl399268537EEEEEdEclEv
LM910:
movl 8(%ebp), %eax # this, this
 movl %eax, (%esp) # this,
 call
__ZN5boost6random6detail19pass_through_engineIRNS0_19linear_congruentialIlLl48271ELl0ELl2147483647ELl399268537EEEEclEv
#
 movl %eax, %ebx #, tmp60
 movl 8(%ebp), %eax # this, this
 movl %eax, (%esp) # this,
call
__ZNK5boost6random6detail19pass_through_engineIRNS0_19linear_congruentialIlLl48271ELl0ELl2147483647ELl399268537EEEE3minEv
#
 subl %eax, %ebx # tmp62,
 movl %ebx, %eax #, tmp63
pushl %eax # tmp63
 fildl (%esp) #
leal 4(%esp), %esp #,
 movl 8(%ebp), %eax # this, this
 fmull 8(%eax) # <variable>._factor
 fstpl -16(%ebp) # result
.stabn
68,0,60,LM911-__ZN5boost10uniform_01INS_6random6detail19pass_through_engineIRNS1_19linear_congruentialIlLl48271ELl0ELl2147483647ELl399268537EEEEEdEclEv
LM911:
fldl -16(%ebp) # result
 fld1
fucompp
fnstsw %ax #
 sahf
ja L843 #,
 jmp L840 #
L843:
.stabn
68,0,61,LM912-__ZN5boost10uniform_01INS_6random6detail19pass_through_engineIRNS1_19linear_congruentialIlLl48271ELl0ELl2147483647ELl399268537EEEEEdEclEv
LM912:
fldl -16(%ebp) # result
LBE365:
LBE364:
LBE363:
LBE362:
LBE361:
addl $20, %esp #,
 popl %ebx #
popl %ebp #
 ret

> Or better, a minimal example to try?

I wish I had one, because then I might be submitting a bug report instead of
asking for help. When I stripped out everything except the retrieval of
random numbers, it worked fine, so obviously I went too far. I'll see what
I can do...

> Which version of GCC are you using (exactly)?

g++ --version reports:
g++ (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net