False positive present in Sonarqube version 8.9.1
This rule as described here Rules explorer Should have an exception when converting to void *
.
However, it seems like it will trigger anyway when converting to a type alias of void *
.
This code is effectively reproducing the issue, and triggers this warning.
using vptr = void *;
int func(vptr ptr);
int main()
{
int a = 1;
func(static_cast<vptr>(&a));
}
Note that using
func(&a);
Also triggers the same warning.
Meanwhile, this does not trigger the warning:
using vptr = void *;
int func(vptr ptr);
int main()
{
int a = 1;
void *p = &a
func(p);
}
It seems logical for a type alias of void *
to get the same exception as the void *
itself.