Realizing f strong typing

Questions and discussions about MISRA C not fitting under migration or rules forums

Moderators: misra-c, david ward

Post Reply
Posts: 1
Joined: Sat Jan 03, 2009 10:26 pm

Realizing f strong typing

Post by B3NN7 » Sat Jan 10, 2009 2:48 pm


I have a problem by realizing a strong typed library function. The library function shall get a pointer to one byte and the number of bytes up on the pointer to be read.

But I does have the requirement that only local variables on the stack or global variables at the data area of the C Application may be processed by my function.

Here is a bad example:

Code: Select all

void function(const void* const Data_pv, const uint8_t Size_u8)

void* Address = 0xFFAF;

function(Address, 8);
It shall not be possible to pass a pointer on void.

Here is a good example

Code: Select all

uint32_t Data_u32 = 5;

function( (uint8_t*)&Data_32, sizeof(Data_u32));

Is there a rule of MISRA C supporting me by realizing my described problem ?

Thanks B3NNY

Posts: 18
Joined: Thu Jul 05, 2007 12:20 am
Company: Disney
Location: Florida

Re: Realizing f strong typing

Post by MMouse » Tue Jun 02, 2009 11:29 am

There isn't realy a single MISRA rule for this. This is inthe catagory of all comments will be meaningful. You need to catch this with human reviewing

See rule 21.1 which says something about run time checking.
You need a static checker with strong typing and dynamic or unit testing.

Post Reply

Return to “General Questions”