<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/92108>92108</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
ubsan complains on rpcgen-generated code, gcc's one silent
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
stsp
</td>
</tr>
</table>
<pre>
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 (char * *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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVUGP4jgT_TXmUiIKDpBwyAGGD6mlmTl8M63VnlqOU0k8beyMXYFlf_3Kxr0MPcNKq201sewqPz9XlV8J71VvEGu22rHVfiYmGqyrPflx1tj2Uj8RiHFE4TzjH0BqYXrGSw9T44UBaY-jFsp4sIble5ZvhQE3yh7NvEeDThC2IG2LYfd5UBqhlzIgXN2vMMqDVxoNZdfVrwPGTeDs1A_6AtraVw9avSLQoDwwXjlsJ4ktEHqaS-GR8Q0rtlcAts7T_3XKC2WknloEVnzw1LbYZQMr_pfM8evJTZLAn-SL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