In a big-endian system, the 64-bit value of 1 is represented as: ``` 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x1 ``` However, when `d.int32_val` is used, this truncates this and takes the first four bytes: ``` 0x0 0x0 0x0 0x0 ``` As a result, we lose the value of 1 from this truncation and the value beocmes 0. This doesn't happen in a little-endian system because the 1 is in the lowest memory address, so truncating the value to 32 bits doesn't change anything. Previously the DefToProto test was failing on a big-endian system because this truncation caused the key to be incorrectly set to 0. We now use the type-specific functions (e.g. `upb_fielddef_defaultint32`) to do this conversion. Closes https://github.com/protocolbuffers/upb/issues/442pull/13171/head
parent
0cb7f72c02
commit
53250c8504
1 changed files with 31 additions and 9 deletions
Loading…
Reference in new issue