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
Hello up there. I was implementing custom RangedSet class via instantiaion of custom RangedMap class with void value type. Unfortunately having that - even empty - value type in the map entry structure increases its size, as the following program demonstrates:
kirr@deca:~/tmp/trashme$ go run zero.go sizeof(KeyRange): 16sizeof(void): 0sizeof(Entry1): 16sizeof(Entry2): 24
What did you expect to see?
I expect that sizeof(Entry1) == sizeof(Entry2) == 16.
What did you see instead?
sizeof(Entry1) == 16, but sizeof(Entry2) == 24 for (imho) no good reason.
The issue is present in all Go versions starting from at least Go1.11, but nevertheless I believe this is a bug.
For the reference: in #40322 the topic of stride alignment being included into sizeof was raised. However in hereby case there is no any extra stride as the KeyRange type is already well aligned to be strided well out of the box.
Thanks beforehand,
Kirill
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Hello up there. I was implementing custom RangedSet class via instantiaion of custom RangedMap class with void value type. Unfortunately having that - even empty - value type in the map entry structure increases its size, as the following program demonstrates:
---- 8< ---- (https://play.golang.org/p/Ed358IA13Fd)
What did you expect to see?
I expect that sizeof(Entry1) == sizeof(Entry2) == 16.
What did you see instead?
sizeof(Entry1) == 16, but sizeof(Entry2) == 24 for (imho) no good reason.
The issue is present in all Go versions starting from at least Go1.11, but nevertheless I believe this is a bug.
For the reference: in #40322 the topic of stride alignment being included into sizeof was raised. However in hereby case there is no any extra stride as the KeyRange type is already well aligned to be strided well out of the box.
Thanks beforehand,
Kirill
The text was updated successfully, but these errors were encountered: