From b4d34d1bc782f6c566448710cb3334bae6b98c36 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sat, 13 Oct 2007 17:01:39 +0000 Subject: [PATCH] Made the C++ array stop if there is a problem with a retyping --- tock_support_cppcsp.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tock_support_cppcsp.h b/tock_support_cppcsp.h index 1a1964b..7202931 100644 --- a/tock_support_cppcsp.h +++ b/tock_support_cppcsp.h @@ -175,6 +175,7 @@ class tockArrayView } friend class tockArrayView; + //TODO change the other methods so we can feed a string in here (the Meta) to report to occam_stop inline void correctDimsRetype(const unsigned totalSourceBytes) { if (totalSubDim == 0) @@ -191,6 +192,13 @@ class tockArrayView else totalDim *= dims[i]; } + + //Check it fits exactly: + if ((totalSourceBytes / totalDim) % sizeof(T) != 0) + { + occam_stop ("","invalid size for RETYPES/RESHAPES (%d does not divide into %d)", (totalSourceBytes / totalDim), sizeof(T)); + } + //Set the size of the unknown dimension: dims[zeroDim] = (totalSourceBytes / totalDim) / sizeof(T);