[HarfBuzz] LLVM Warnings on Mac

Behdad Esfahbod behdad at behdad.org
Wed Nov 6 11:47:26 PST 2013


On 13-11-05 07:53 PM, Scott Fleischman wrote:
> I getting the following warnings using a basic Xcode 5 project to build
> HarfBuzz 0.9.23 (with hb-ft) on Mac OS X, targeting 10.6, 32-bit Intel (i386),
> using the default compiler (Apple LLVM 5.0).
> 
> harfbuzz/src/hb-font-private.hh:121:42: Implicit conversion loses integer
> precision: 'long long' to 'hb_position_t' (aka 'int')
> harfbuzz/src/hb-font-private.hh:126:42: Implicit conversion loses integer
> precision: 'long long' to 'hb_position_t' (aka 'int')
> harfbuzz/src/hb-font-private.hh:400:85: Implicit conversion loses integer
> precision: 'long long' to 'hb_position_t' (aka 'int')
> harfbuzz/src/hb-ot-layout-common-private.hh:1115:37: Implicit conversion loses
> integer precision: 'long long' to 'int'
> harfbuzz/src/hb-ft.cc:421:97: Implicit conversion loses integer precision:
> 'unsigned long long' to 'int'
> harfbuzz/src/hb-ft.cc:422:97: Implicit conversion loses integer precision:
> 'unsigned long long' to 'int'
> 
> 
> All the cases seem to be multiplying by a scale casted to int64 to prevent
> overflow, then dividing by the scale. Explicitly casting the result silences
> the warnings. Is there a better solution?

Applied.  Thanks.

behdad

> Thanks,
> 
> Scott Fleischman
> 
> 
> 
> diff --git a/src/hb-font-private.hh b/src/hb-font-private.hh
> index 00c0cc3..aa6c515 100644
> --- a/src/hb-font-private.hh
> +++ b/src/hb-font-private.hh
> @@ -118,12 +118,12 @@ struct hb_font_t {
>    /* Convert from parent-font user-space to our user-space */
>    inline hb_position_t parent_scale_x_distance (hb_position_t v) {
>      if (unlikely (parent && parent->x_scale != x_scale))
> -      return v * (int64_t) this->x_scale / this->parent->x_scale;
> +      return (hb_position_t) (v * (int64_t) this->x_scale /
> this->parent->x_scale);
>      return v;
>    }
>    inline hb_position_t parent_scale_y_distance (hb_position_t v) {
>      if (unlikely (parent && parent->y_scale != y_scale))
> -      return v * (int64_t) this->y_scale / this->parent->y_scale;
> +      return (hb_position_t) (v * (int64_t) this->y_scale /
> this->parent->y_scale);
>      return v;
>    }
>    inline hb_position_t parent_scale_x_position (hb_position_t v) {
> @@ -397,7 +397,7 @@ struct hb_font_t {
>    }
>  
>    private:
> -  inline hb_position_t em_scale (int16_t v, int scale) { return v * (int64_t)
> scale / face->get_upem (); }
> +  inline hb_position_t em_scale (int16_t v, int scale) { return
> (hb_position_t) (v * (int64_t) scale / face->get_upem ()); }
>  };
>  
>  #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
> diff --git a/src/hb-ft.cc b/src/hb-ft.cc
> index 113b0eb..44e0b0b 100644
> --- a/src/hb-ft.cc
> +++ b/src/hb-ft.cc
> @@ -418,8 +418,8 @@ hb_ft_font_create (FT_Face           ft_face,
>                      _hb_ft_get_font_funcs (),
>                      ft_face, (hb_destroy_func_t) _do_nothing);
>    hb_font_set_scale (font,
> -                    ((uint64_t) ft_face->size->metrics.x_scale * (uint64_t)
> ft_face->units_per_EM + (1<<15)) >> 16,
> -                    ((uint64_t) ft_face->size->metrics.y_scale * (uint64_t)
> ft_face->units_per_EM + (1<<15)) >> 16);
> +                    (int) (((uint64_t) ft_face->size->metrics.x_scale *
> (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16),
> +                    (int) (((uint64_t) ft_face->size->metrics.y_scale *
> (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16));
>    hb_font_set_ppem (font,
>                     ft_face->size->metrics.x_ppem,
>                     ft_face->size->metrics.y_ppem);
> diff --git a/src/hb-ot-layout-common-private.hh
> b/src/hb-ot-layout-common-private.hh
> index 1e75930..367db95 100644
> --- a/src/hb-ot-layout-common-private.hh
> +++ b/src/hb-ot-layout-common-private.hh
> @@ -1112,7 +1112,7 @@ struct Device
>  
>      if (!pixels) return 0;
>  
> -    return pixels * (int64_t) scale / ppem;
> +    return (int) (pixels * (int64_t) scale / ppem);
>    }
> 
> 
> 
> _______________________________________________
> HarfBuzz mailing list
> HarfBuzz at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/harfbuzz
> 

-- 
behdad
http://behdad.org/



More information about the HarfBuzz mailing list