1
votes

My CCS 6.1 ARM compiler (for LM3Sxxxx Stellaris) throws a warning:

"MISRA Rule 10.1. The value of an expression of integer type shall not be implicitly converted to a different underlying type if the expression is not constant and is a function argument"

for following code:

static uint32_t diagBaseAddress;

void diagCbGetBaseAddress(uint32_t * addr);

...
diagCbGetBaseAddress(&diagBaseAddress); // line where warning is issued
...

I don't see a problem in my code. Is it false positive or my bug?

1
Seemss like a wrong warning. Are you sure this is the entire code? Is there no const or volatile thrown in? - fuz
There is no such modifier. I got these in every function call where parameters were passed by reference, but the types are correct like in this sample. - tk_
The message would be correct if you forgot the & address-of operator. Sure it's there? - Jens
Yes the & is there, if omitted the sample would not compile at all. The code normally works but maybe the TI CCS Misra checker is buggy? I asked because I could not imagine it would issue false warnings for such a simple code. - tk_
I think answer is here: stackoverflow.com/questions/32554813/… - tk_

1 Answers

1
votes

Yes, it is a false positive. Rule 10.1 of MISRA-C:2004 is concerned about implicit type promotions of integer types. Pointers have nothing to do with that rule.

Though make sure that none of the adjacent code lines contain the actual problem, the tool could simply be pointing at the wrong line.

(I can tell it is the 2004 version because it mentions underlying type. In the 2012 version, the concept of underlying type was replaced.)