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

Incorrect accessors generated in the presence of an anonymous union containing nested structures #129

Open
KislyjKisel opened this issue Jan 28, 2024 · 2 comments

Comments

@KislyjKisel
Copy link

C definition: https://github.com/blend2d/blend2d/blob/597ea5d5c35c6d3dfdc2329316f1d8ba25929404/src/blend2d/format.h#L118-L141

(let ((format (autowrap:alloc 'format-info)))
  (format t "DEPTH   ~a~%" (format-info.depth& format))
  (format t "FLAGS   ~a~%" (format-info.flags& format))
  (format t "SIZES   ~a~%" (format-info.sizes[]& format))
  (format t "R-SIZE  ~a~%" (format-info.r-size& format))
  (format t "PALETTE ~a~%" (format-info.palette& format)))

r-size and sizes are expected to have the same address as palette because they are in the same union, but instead have the address of the parent struct, same as depth.

DEPTH   #.(SB-SYS:INT-SAP #X00D7BCB0)
FLAGS   #.(SB-SYS:INT-SAP #X00D7BCB4)
SIZES   #.(SB-SYS:INT-SAP #X00D7BCB0)
R-SIZE  #.(SB-SYS:INT-SAP #X00D7BCB0)
PALETTE #.(SB-SYS:INT-SAP #X00D7BCB8)

Platform: Linux x86-64, SBCL.

@rpav
Copy link
Owner

rpav commented Apr 20, 2024

A million years later, but is this still an issue? Did you check the c2ffi output, or try with a newer clang? I don't think autowrap/sffi itself does any computation for field offsets (outside of array indexing).

@KislyjKisel
Copy link
Author

KislyjKisel commented Apr 22, 2024

c2ffi outputs fields with offsets relative to the nearest parent record. autowrap seems to account for this with pre-offset parameter. Here, if I understand correctly, nested records are parsed, but their pre-offset is set to the field's bit-offset. If the field's bit-offset isn't absolute there, than it should be (+ pre-offset (or bit-offset 0)) instead.

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

2 participants