Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix MC builds with gcc12 (and make the serialization more robust)
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 13 Feb 2022 10:24:24 +0000 (11:24 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 13 Feb 2022 10:24:24 +0000 (11:24 +0100)
src/mc/api/Transition.hpp
src/mc/api/TransitionComm.cpp

index 3ee9110..ed4dd75 100644 (file)
@@ -32,7 +32,8 @@ class Transition {
   friend State; // FIXME remove this once we have a proper class to handle the statistics
 
 public:
-  XBT_DECLARE_ENUM_CLASS(Type, UNKNOWN, RANDOM, COMM_RECV, COMM_SEND, COMM_TEST, COMM_WAIT, TESTANY);
+  XBT_DECLARE_ENUM_CLASS(Type, RANDOM, COMM_RECV, COMM_SEND, COMM_TEST, COMM_WAIT, TESTANY,
+                         /* UNKNOWN must be last */ UNKNOWN);
   Type type_ = Type::UNKNOWN;
 
   aid_t aid_ = 0;
index 259accc..21a827c 100644 (file)
@@ -239,6 +239,9 @@ Transition* recv_transition(aid_t issuer, int times_considered, std::stringstrea
 {
   short type;
   stream >> type;
+  xbt_assert(type >= 0 && type <= static_cast<short>(Transition::Type::UNKNOWN), "Invalid transition type %d received",
+             type);
+
   Transition::Type simcall = static_cast<Transition::Type>(type);
 
   switch (simcall) {
@@ -259,9 +262,8 @@ Transition* recv_transition(aid_t issuer, int times_considered, std::stringstrea
 
     case Transition::Type::UNKNOWN:
       return new Transition(Transition::Type::UNKNOWN, issuer, times_considered);
-    default:
-      xbt_die("recv_transition of type %s unimplemented", Transition::to_c_str(simcall));
   }
+  THROW_IMPOSSIBLE; // Some compilers don't detect that each branch of the above switch has a return
 }
 
 } // namespace mc