Fwd: Expecting warning in int to short implicit conversion

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Fwd: Expecting warning in int to short implicit conversion

Hans Wennborg via cfe-dev
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
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev