SilverFruity / OCRunner

Execute Objective-C code as script. AST Interpreter. iOS hotfix SDK.
MIT License
660 stars 149 forks source link

结构体的内存对齐规则,有瑕疵,当存在嵌套结构体时,计算偏移量错误 #26

Closed windfanstry closed 1 year ago

windfanstry commented 2 years ago

OCRunner version: master分支

description: 嵌套结构体时,内部嵌套的结构体的偏移对齐值,不能按照它的尺寸来定义,而是由它的最大的基础变量的尺寸决定的

example: `struct A { int a1; char a2; }; struct B { char b1; struct A b2; };

struct B s1 = {1,{2,3}};`

OCRunner 版本号: xxx

问题描述: EFF67DC1-36D1-44BF-B15B-6A8902161190

计算结构体内部变量的偏移量时,当遇到structA这种,嵌套结构体时,它的size是8,但它的对齐偏移值应该是4,在structB中b2变量的offset应该是4,这里错误计算为8.

bug 示例代码: