diff options
author | Josh Haberman <jhaberman@gmail.com> | 2015-06-03 14:51:18 -0700 |
---|---|---|
committer | Josh Haberman <jhaberman@gmail.com> | 2015-06-03 14:51:18 -0700 |
commit | 6f30032183ccd20d7a7f031ebc9350f54179bba8 (patch) | |
tree | d11ff95cbe3a34a65804c163781c7e98ffc1f7af /upb/bindings/lua/upb.c | |
parent | 838009ba2b8ea1e99061c66e0fbd9cb53a96ec20 (diff) |
Sync from Google-internal development.
Diffstat (limited to 'upb/bindings/lua/upb.c')
-rw-r--r-- | upb/bindings/lua/upb.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/upb/bindings/lua/upb.c b/upb/bindings/lua/upb.c index b35af24..02057d4 100644 --- a/upb/bindings/lua/upb.c +++ b/upb/bindings/lua/upb.c @@ -1358,6 +1358,18 @@ static size_t align_up(size_t val, size_t align) { // If we always read/write as a consistent type to each value, this shouldn't // violate aliasing. +// +// Note that the slightly prettier option of: +// +// *(type*)(&msg->data[ofs]) +// +// ...is potentially more questionable wrt the C standard and aliasing. +// Does the expression &msg->data[ofs] "access the stored value"? If so, +// this would violate aliasing. So instead we use the expression: +// +// (char*)msg + sizeof(lupb_msg) + ofs +// +// ...which unambigiously is doing nothing but calculating a pointer address. #define DEREF(msg, ofs, type) *(type*)((char*)msg + sizeof(lupb_msg) + ofs) lupb_msg *lupb_msg_check(lua_State *L, int narg) { |