translate-c: take address of functions before passing them to @ptrToInt
Fixes #12194
This commit is contained in:
committed by
Veikka Tuominen
parent
c8c798685f
commit
7ba1f9bfb5
@@ -1861,4 +1861,18 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void {
|
||||
\\ return 0;
|
||||
\\}
|
||||
, "");
|
||||
|
||||
// The C standard does not require function pointers to be convertible to any integer type.
|
||||
// However, POSIX requires that function pointers have the same representation as `void *`
|
||||
// so that dlsym() can work
|
||||
cases.add("Function to integral",
|
||||
\\#include <stdint.h>
|
||||
\\int main(void) {
|
||||
\\#if defined(__UINTPTR_MAX__) && __has_include(<unistd.h>)
|
||||
\\ uintptr_t x = main;
|
||||
\\ x = (uintptr_t)main;
|
||||
\\#endif
|
||||
\\ return 0;
|
||||
\\}
|
||||
, "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user