FreeFem / FreeFem-sources

FreeFEM source code
https://freefem.org/
Other
746 stars 187 forks source link

error: use of overloaded operator '=' is ambiguous (with operand types 'KN<idx_t>' (aka 'KN<long>') and 'int') #280

Closed yurivict closed 1 year ago

yurivict commented 1 year ago

Build fails:

metis.cpp:100:16: error: use of overloaded operator '=' is ambiguous (with operand types 'KN<idx_t>' (aka 'KN<long>') and 'int')
  } else epart = 0;
         ~~~~~ ^ ~
./include/RNM.hpp:993:8: note: candidate function
   KN& operator  = (R*  a) { CheckSet(); return operator =(KN_<R>(a,this->n));}
       ^
./include/RNM.hpp:1010:8: note: candidate function
   KN& operator =(const_R a)
       ^
metis.cpp:157:16: error: use of overloaded operator '=' is ambiguous (with operand types 'KN<idx_t>' (aka 'KN<long>') and 'int')
  } else epart = 0;
         ~~~~~ ^ ~
./include/RNM.hpp:993:8: note: candidate function
   KN& operator  = (R*  a) { CheckSet(); return operator =(KN_<R>(a,this->n));}
       ^
./include/RNM.hpp:1010:8: note: candidate function
   KN& operator =(const_R a)
       ^
metis.cpp:181:58: warning: format specifies type 'int' but the argument has type 'idx_t' (aka 'long') [-Wformat]
      printf("  %d-way Edge-Cut: %7d, Balance: %5.2f\n", nparts, nve,
                ~~                                       ^~~~~~
                %ld
metis.cpp:181:66: warning: format specifies type 'int' but the argument has type 'idx_t' (aka 'long') [-Wformat]
      printf("  %d-way Edge-Cut: %7d, Balance: %5.2f\n", nparts, nve,
                                 ~~~                             ^~~
                                 %7ld
metis.cpp:187:16: error: use of overloaded operator '=' is ambiguous (with operand types 'KN<idx_t>' (aka 'KN<long>') and 'int')
  } else epart = 0;
         ~~~~~ ^ ~
./include/RNM.hpp:993:8: note: candidate function
   KN& operator  = (R*  a) { CheckSet(); return operator =(KN_<R>(a,this->n));}
       ^

Version: 4.13 clang-15 FreeBSD 13.2

prj- commented 1 year ago

Does the following patch fixes your issue?

diff --git a/plugin/seq/metis.cpp b/plugin/seq/metis.cpp
index da7bcb6b..c4b1b580 100644
--- a/plugin/seq/metis.cpp
+++ b/plugin/seq/metis.cpp
@@ -99,3 +99,3 @@ KN< R > *partmetis( KN< R > *const &part, FESPACE *const &pVh, long const &lpart
 #endif
-  } else epart = 0;
+  } else epart = static_cast<idx_t>(0);
   part->resize(nv);
@@ -156,3 +156,3 @@ KN< R > *partmetis(Stack s, KN< R > *const &part, Mesh *const &pTh, long const &
 #endif
-  } else epart = 0;
+  } else epart = static_cast<idx_t>(0);
   part->resize(nt);
@@ -186,3 +186,3 @@ KN< long > *partmetisd(Stack s, KN< long > *const &part, Mesh *const &pTh, long
 #endif
-  } else epart = 0;
+  } else epart = static_cast<idx_t>(0);
   part->resize(nt);
yurivict commented 1 year ago

This patch fixes the problem.

prj- commented 1 year ago

Thanks for your feedback.