Skip to content

[SYCL][UR] Fix post commit Windows failure #17574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sycl/source/detail/os_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ void *dynLookup([[maybe_unused]] const char *WinName,
"Symbol " + std::string(FunName) +
" could not be found");
}
return retVal;
return reinterpret_cast<void *>(retVal);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it still UB?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, https://en.cppreference.com/w/cpp/language/reinterpret_cast:

On some implementations (in particular, on any POSIX compatible system as required by dlsym), a function pointer can be converted to void* or any other object pointer, or vice versa. If the implementation supports conversion in both directions, conversion to the original type yields the original value, otherwise the resulting pointer cannot be dereferenced or called safely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would appear so. In which case the return type should be changed, perhaps void (*)(void).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our case it's probably fine, though. We can look into making the version that doesn't reply on language extensions in a future commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the error was about an implicit cast, not the fact that we are casting at all. I guess FARPROC is some kind of function pointer type on clang?

I think on all platforms we support, casting two and from functions and objects works. I could be wrong though.

}

} // namespace detail
Expand Down
Loading