On 10/19/12, Richard Biener <richard.guent...@gmail.com> wrote:
> The existing tree_low_cst function performs checking, so
> tree_to_hwi should as well.
>
> I don't think mismatch of signedness of the variable assigned to
> with the sign we use for hwi extraction is any good.  C++ isn't
> type-safe here for the return value but if we'd use a reference
> as return slot we could make it so ...  (in exchange for quite
> some ugliness IMNSHO):
>
> void tree_to_shwi (const_tree tree, HOST_WIDE_INT &hwi);
>
> vs.
>
> void tree_to_uhwi (const_tree tree, unsigned HOST_WIDE_INT &hwi);
>
> maybe more natural would be
>
> void hwi_from_tree (HOST_WIDE_INT &hwi, const_tree tree);
> void hwi_from_tree (unsigned HOST_WIDE_INT &hwi, const_tree tree);
>
> let the C++ bikeshedding begin!  (the point is to do appropriate
> checking for a conversion of (INTEGER_CST) tree to HOST_WIDE_INT
> vs.  unsigned HOST_WIDE_INT)

We could add conversion operators to achieve the effect.  However,
we probably don't want to do so until we can make them explicit.
Unfortunately, explicit conversion operators are not available
until C++11.

> No, I don't want you to do the above transform with this patch ;)

-- 
Lawrence Crowl

Reply via email to