MISRA Discussion Forums
size_t and Rule 3-9-2 - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18)
+--- Forum: MISRA C++:2008 rules (https://forum.misra.org.uk/forumdisplay.php?fid=19)
+---- Forum: 6.3 Basic concepts (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=132)
+---- Thread: size_t and Rule 3-9-2 (/showthread.php?tid=1130)



size_t and Rule 3-9-2 - markturney - 21-11-2014

Hello,

Rule 3-9-2 states that "typedefs that indicate size and signedness should be used in place of the basic numerical types."

It specifically states that "The basic numerical types of char, int, short, long, float, double and long double should not be used, but specific-length typedefs should be used."

What about size_t? The signedness is known, but the specific-length is not.

Does this code snippet violate 3-9-2?

Code:
std::vector collection(3, 5);

for (std::size_t ii = 0, count = collection.size(); ii < count; ++ii)
{
    processElement(collection[ii]);
}

Thank you for the help,
Mark


Re: size_t and Rule 3-9-2 - misra cpp - 11-10-2016

size_t not a basic numerical type as defined by the rule, so the rule does not apply