<p dir="auto">by <strong>smith.malcolm.james</strong>:</p>
<pre class="notranslate">Calling syscall with float32 arguments passes the values correctly to the dll. But the
float32 return value is incorrect

What steps will reproduce the problem?

visual C++ 6.0 program:
#include "stdafx.h"
#include &lt;stdio.h&gt;
 extern "C"  __declspec(dllexport) float addfloat( float a, float b) ;
BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
                     )
{
    return TRUE;
}
  float addfloat ( float a, float b)
{
    printf("In dll: %f %f\n", a,b);
    return a+b;
}

Go program:
package main
import (
    "fmt"
    "math"
    "syscall"
)
var mylib = syscall.NewLazyDLL("mylib.dll")
var addfloat = mylib.NewProc("addfloat")
func main() {

    r1, r2, _ := addfloat.Call(uintptr(math.Float32bits(1.1)) , uintptr(math.Float32bits(2.2)))

    fmt.Println("r1 and r2 as uintptr", r1, r2)
    fmt.Println("3.3 as uintptr", uintptr(math.Float32bits(3.3)))

    r1, r2, _ = addfloat.Call(uintptr(math.Float32bits(3.3)) , uintptr(math.Float32bits(4.4)))

    fmt.Println("r1 and r2 as uintptr", r1, r2)
    fmt.Println("7.7 as uintptr", uintptr(math.Float32bits(7.7)))
}


What is the expected output?
Expect r1 to hold IEEE 754 binary representation of 3.3 after 1st call and 7.7 after 2nd
call

What do you see instead?
r1 holds 26 after both 1st and 2nd calls

Sample output:
In dll: 1.100000 2.200000
r1 and r2 as uintptr 26 821312832
3.3 as uintptr 1079194419
In dll: 3.300000 4.400000
r1 and r2 as uintptr 26 821312832
7.7 as uintptr 1089889894

Which compiler are you using (5g, 6g, 8g, gccgo)?
8g

Which operating system are you using?
Windows XP

Which version are you using?  (run 'go version')
go1

Please provide any additional information below.
Integer values are returned with no problem. The code in
src\pkg\runtime\sys_windows_386.s looks as if it is expecting return values to be in the
AX and DX registers, but float values are returned in the ST0 register.</pre>
<p dir="auto">by <strong>arnaud.lb</strong>:</p>
<pre class="notranslate">What does 'go version' print?

go version go1.3 darwin/amd64

What steps reproduce the problem?

1. go build -gcflags "-N -l" x.go # x.go attached
2. ./x
3. gdb -p &lt;pid&gt;
4. info goroutines

What happened?

(gdb) info goroutines
Python Exception &lt;class 'gdb.error'&gt; Attempt to extract a component of a value
that is not a (null).:
Error occurred in Python command: Attempt to extract a component of a value that is not
a (null).
(gdb)

Happens with the goroutines command too:

(gdb) goroutine 123 bt
Python Exception &lt;class 'gdb.error'&gt; Attempt to extract a component of a value
that is not a (null).:
Error occurred in Python command: Attempt to extract a component of a value that is not
a (null).
(gdb)

Please provide any additional information below.

gdb version 7.7.1</pre>
<p dir="auto">Attachments:</p>
<ol dir="auto">
<li><a href="https://storage.googleapis.com/go-attachment/8251/0/x.go" rel="nofollow">x.go</a> (124 bytes)</li>
</ol>