[email protected] writes:

> From: Yichao Yu <[email protected]>
>
> There's no overload for `std::abs` or `abs` that takes `unsigned int` as 
> input so this causes
> an ambiguity when both `std::abs` and `abs` are available in the namespace.
> Explicitly cast the `unsigned int` to `int` to resolve the ambiguity.
[...]
>                unsigned int s0 = src0.value.ud;
>                if (src0.absolute)
> -                s0 = abs(s0);
> +                s0 = abs((int)s0);

Can you add `assert(s0 <= INT_MAX)` before abs() call? Otherwise, a value
between INT_MAX and UINT_MAX may overflow `int` (or `long` with -m32).

$ cat >a.cc
#include <climits>
#include <iostream>

int main()
{
    unsigned int s0 = UINT_MAX;
    s0 = std::abs((int)s0);
    std::cout << s0 << std::endl;
    return 0;
}

$ c++ a.cc
$ ./a.out
1
_______________________________________________
Beignet mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/beignet

Reply via email to