size_t and Rule 3-9-2

Moderators: david ward, misra cpp

markturney
Posts: 2
Joined: Thu Nov 20, 2014 5:58 pm
Company: Energid

size_t and Rule 3-9-2

Postby markturney » Fri Nov 21, 2014 2:34 pm

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: Select all

std::vector<int32_t> collection(3, 5);

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


Thank you for the help,
Mark

misra cpp
Posts: 145
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

Re: size_t and Rule 3-9-2

Postby misra cpp » Tue Oct 11, 2016 10:23 am

size_t not a basic numerical type as defined by the rule, so the rule does not apply
Posted by and on behalf of
the MISRA C++ Working Group


Return to “6.3 Basic concepts (C++)”

Who is online

Users browsing this forum: No registered users and 5 guests