Dir 4.6 and usage of "fast" types in stdint.h

Moderators: misra-c, david ward

Post Reply
michael.metivier
Posts: 10
Joined: Thu Mar 21, 2013 7:30 pm
Company: Gentex, Corp.

Dir 4.6 and usage of "fast" types in stdint.h

Post by michael.metivier » Thu Oct 12, 2017 9:31 pm

Directive 4.6 indicates "typedefs that indicate sign and signedness should be used in place of the basic numerical types" and suggests that, for C99-compliant systems, the types of <stdint.h> should be used.

stdint.h also defines "fast" types which are at least of the indicated length, but may be larger if such a length could be handled more efficiently by the processor.

Is it a violation of Directive 4.6 to utilize these types? They are not "basic numerical types", but also do not necessarily adhere to a fixed length as specified by their names.

misra-c
Posts: 556
Joined: Thu Jan 05, 2006 1:11 pm

Re: Dir 4.6 and usage of "fast" types in stdint.h

Post by misra-c » Fri Dec 08, 2017 9:33 am

The use of types such as int_fast8_t and int_least8_t violates Directive 4.6.

The amplification to directive 4.6 states:
A type must not be defined with a specific length unless the implemented type is actually of that length.
The use of types such as int_fast8_t and int_least8_t does not guarantee that the type is actually of 8-bits.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “7.4 Code design”