[cfe-dev] Fwd: Expecting warning in int to short implicit conversion

Lokesh Janghel via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 30 04:57:43 PST 2020


Hi devs,

Please consider below two cases.

case 1:

void foo1 ()
{
    short val = 0, x = 1;
    val = (5 * x); // Here we expect implicit conversion( from int to
short) warning
                        // but clang does not warn with( -Wconversion).
}

case 2:

void foo2 ()
{
    short val = 0;
    int i = 1;
    val = (4 * i) ; // but in this case clang does warn with( -Wconversion).
}
...

GCC gives warning with( -Wconversion) for both test cases.
Like to know the community's thoughts on why clang does not warn for
the first case.
Here is Godbolt link for the above case:
https://godbolt.org/z/P6nQZ4

Thanks
Lokesh


More information about the cfe-dev mailing list