Open
Description
It appears, clang's ubsan complains on
an rpcgen-generated code, while gcc's
ubsan is silent.
The code roughly looks like this (reduced test-case):
#include <stddef.h>
struct svc_req;
static int
_a_1 (void *argp, void *result, struct svc_req *rqstp)
{
return 0;
}
int main()
{
int (*local)(char *, void *, struct svc_req *);
local = (int (*) (char *, void *, struct svc_req *))_a_1;
return local(NULL, NULL, NULL);
}
Now do this:
$ gcc -Wall -fsanitize=undefined tst.c
$ ./a.out
$ clang -Wall -fsanitize=undefined tst.c
$ ./a.out
tst.c:15:9: runtime error: call to function _a_1 through pointer to incorrect function type 'int (*)(char *, void *, struct svc_req *)'
tst.c: note: _a_1 defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tst.c:15:9
As can be seen, only clang complained.
I don't know if it is a real UB or a false-positive.
But as gcc keeps silence, I assume this is
a false-positive.
There is no way to "just fix" the code, as it
is generated by rpcgen.