Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struc.Float16 does not work with slices #66

Open
curio77 opened this issue Apr 15, 2019 · 5 comments
Open

struc.Float16 does not work with slices #66

curio77 opened this issue Apr 15, 2019 · 5 comments

Comments

@curio77
Copy link

curio77 commented Apr 15, 2019

If I have a format definition like this:

type format struct {
    Field struc.Float16 `struc:"float16,little"`
    Fields [42]struc.Float16 `struc:"[42]float16,little"`
}

then upon unpacking (haven't checked if it affects packing as well), Field will parse two bytes (as expected), but Fields will wrongly try to parse 42 × 8 bytes (the size of float64 which struc.Float16 equates to) instead of 42 × 2.

@lunixbochs
Copy link
Owner

Can you try with this PR? #63

@curio77
Copy link
Author

curio77 commented Apr 16, 2019

That gives me a panic: array/slice of custom struct is not supported: [42]struc.Float16.

@13rac1
Copy link
Contributor

13rac1 commented Jun 5, 2019

@curio77 That's by design. The logic is: A panic is a better than working wrong. See #65

@andig
Copy link

andig commented May 21, 2020

To summarize: #63 does fix the broken behavior by explicit panic which is good. Op‘s original issue of slice of struct not supported remains.

@andig
Copy link

andig commented May 21, 2020

@lunixbochs wouldn‘t it make sense to merge #63? @13rac1 are you maintaining a fork intendend for public usage?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants