You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. Compile and run the following demo program:
package main
import (
"os"
"encoding/binary"
)
type DemoType struct {
x,y int
}
func main() {
x := DemoType{1,2}
fd, _ := os.Open("demofile.bin", os.O_RDWR|os.O_CREAT, 0600)
defer fd.Close()
binary.Write(fd, binary.LittleEndian, x)
}
What is the expected output?
I would expect the compiler to bail out and report an error since the size of 'int' is
not defined in the language standard. Therefore, the written output would be
compiler/architecture dependent. The same applies to using the 'float' type in the
struct.
Instead, the compiler could print an error that it expects the size of the used data
types to be of fixed width (int32, int64, float32 etc.).
What do you see instead?
Program compiles fine. It outputs a file containing 8 zero-valued bytes.
Which compiler are you using (5g, 6g, 8g, gccgo)?
8g on Linux
6g on Mac OS X
Which operating system are you using?
Linux (8g)
Mac OS X (6g)
Which revision are you using? (hg identify)
25631
The text was updated successfully, but these errors were encountered:
I have a couple of fixes for this issue--the first is localized to encoding/binary, the
second involves some changes to gc, ld, runtime, and reflect. Is it worth submitting a
CL for either of these, and if so, which one? I've included patches for either fix in
the attached tarball.
by thomas.e.zander:
The text was updated successfully, but these errors were encountered: