[flang-commits] [flang] [flang] Use std::uintptr_t instead of unsigned long for better cross-platform stability (PR #183913)
via flang-commits
flang-commits at lists.llvm.org
Mon Mar 2 07:59:17 PST 2026
================
@@ -253,31 +253,17 @@ constexpr TypeBuilderFunc getModel<void (*)(int)>() {
}
template <>
constexpr TypeBuilderFunc
-getModel<void *(*)(void *, const void *, unsigned long)>() {
+getModel<void *(*)(void *, const void *, std::uintptr_t)>() {
----------------
jeanPerier wrote:
Looking at [git blame](https://github.com/llvm/llvm-project/commit/a0dfe4503654ad8e6c83f197ae3f73c81b271110#diff-2744ba7fb9dfb570d76519025c82f8a6ab905c700c8e160761fa091160bd0300), this code was added to deal with `std::size_t`, but as Eugene mentioned, template collision could be an issue so I also prefer adding the needed `unsigned long long` overload instead of adding an entry for the alias hopping that it will not collide with other entries on all platform.
For instance, if a runtime entry point is added that explicitly uses `unsigned long` for some reason, then it will not be possible to add the `getModel` for it without reverting your change because it will be missing on platforms where `std::uintptr_t` resolves to `unsigned long long`, but adding a new definition for `unsigned long` will cause conflicts for platforms where `std::size_t` resolves `unsigned long`.
So it is just easier to rule that the `getModel` should be defined on native types and not aliases.
Once this glue code is moved to something that allows cross compilation and is probably not C++ template based, this can simplified.
https://github.com/llvm/llvm-project/pull/183913
More information about the flang-commits
mailing list