diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index b56cd7462..6fef9240f 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -234,6 +234,15 @@ hb_ctz (T v) * Tiny stuff. */ +template +T* hb_addressof (T& arg) +{ + /* https://en.cppreference.com/w/cpp/memory/addressof */ + return reinterpret_cast( + &const_cast( + reinterpret_cast(arg))); +} + /* ASCII tag/character handling */ static inline bool ISALPHA (unsigned char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); } diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index 4adad6017..33b7070ee 100644 --- a/src/hb-ot-post-table.hh +++ b/src/hb-ot-post-table.hh @@ -168,7 +168,8 @@ struct post } hb_bytes_t st (name, len); - const uint16_t *gid = (const uint16_t *) hb_bsearch_r (&st, gids, count, sizeof (gids[0]), cmp_key, (void *) this); + const uint16_t *gid = (const uint16_t *) hb_bsearch_r (hb_addressof (st), gids, count, + sizeof (gids[0]), cmp_key, (void *) this); if (gid) { *glyph = *gid;