Skip to content

[flang] Match argument types for std::min #71102

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 2 commits into from
Nov 6, 2023
Merged

Conversation

kkwli
Copy link
Collaborator

@kkwli kkwli commented Nov 2, 2023

PR #68342 causes build breakage on MacOS due to uint64_t being defined as unsigned long long instead of unsigned long. It leads to type mismatch in the arguments for std::min.

PR#68342 causes build breakage on MacOS due to uint64_t being defined as
unsigned long long instead of unsigned long. It leads to type mismatch
in the arguments for std::min.
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Nov 2, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 2, 2023

@llvm/pr-subscribers-flang-semantics

Author: None (kkwli)

Changes

PR #68342 causes build breakage on MacOS due to uint64_t being defined as unsigned long long instead of unsigned long. It leads to type mismatch in the arguments for std::min.


Full diff: https://github.com/llvm/llvm-project/pull/71102.diff

1 Files Affected:

  • (modified) flang/lib/Evaluate/fold-implementation.h (+3-1)
diff --git a/flang/lib/Evaluate/fold-implementation.h b/flang/lib/Evaluate/fold-implementation.h
index 868b7b6990fd384..800dc6b75698c86 100644
--- a/flang/lib/Evaluate/fold-implementation.h
+++ b/flang/lib/Evaluate/fold-implementation.h
@@ -910,7 +910,9 @@ template <typename T> Expr<T> Folder<T>::RESHAPE(FunctionRef<T> &&funcRef) {
                 : pad->Reshape(std::move(shape.value()))};
         ConstantSubscripts subscripts{result.lbounds()};
         auto copied{result.CopyFrom(*source,
-            std::min(source->size(), resultElements), subscripts, dimOrderPtr)};
+            std::min(static_cast<decltype(resultElements)>(source->size()),
+                resultElements),
+            subscripts, dimOrderPtr)};
         if (copied < resultElements) {
           CHECK(pad);
           copied += result.CopyFrom(

@kkwli kkwli requested a review from luporl November 2, 2023 23:41
Copy link
Contributor

@luporl luporl left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for fixing it.

@kkwli kkwli self-assigned this Nov 6, 2023
@kkwli kkwli merged commit 5fc6913 into llvm:main Nov 6, 2023
@kkwli
Copy link
Collaborator Author

kkwli commented Nov 6, 2023

@luporl Thanks for the review.

@kkwli kkwli deleted the mac-build-break branch November 6, 2023 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants