EmbeddedRelated.com
Forums

IAR complier warning/error on size mismatch

Started by sureshaps August 11, 2012
Hi All,

may I check if there is any setting to make IAR to throw error/warning
whenever value contained in large sized variable(32 bit) is assingned
to small one(16bit) .

in one of our function we assign 32bit global variable to a local
variable of size 16 bit unknowingly and end up in truncated value in
local var which caused big havoc.

Thanks in advance.

Suresh

Beginning Microcontrollers with the MSP430

MISRA C will check that for you

Same for 16 into 8 or 32 into 8

From: m... [mailto:m...] On Behalf
Of sureshaps
Sent: Saturday, August 11, 2012 1:29 AM
To: m...
Subject: [msp430] IAR complier warning/error on size mismatch

Hi All,

may I check if there is any setting to make IAR to throw error/warning
whenever value contained in large sized variable(32 bit) is assingned
to small one(16bit) .

in one of our function we assign 32bit global variable to a local
variable of size 16 bit unknowingly and end up in truncated value in
local var which caused big havoc.

Thanks in advance.

Suresh



Hi Hugo Brunert,
 
Thanks for the suggestion.
we don/t use MISRA C guide lines in our coding and this option is disabled in seetings. 
 
I was trying to explore if there are any other way of specifying compilation options to check this kind of errors.
 
Thanks & rgds,
Suresh.

 

________________________________
From: Hugo Brunert
To: m...
Sent: Saturday, August 11, 2012 6:30 PM
Subject: RE: [msp430] IAR complier warning/error on size mismatch



 

MISRA C will check that for you

Same for 16 into 8 or 32 into 8

From: mailto:msp430%40yahoogroups.com [mailto:mailto:msp430%40yahoogroups.com] On Behalf
Of sureshaps
Sent: Saturday, August 11, 2012 1:29 AM
To: mailto:msp430%40yahoogroups.com
Subject: [msp430] IAR complier warning/error on size mismatch

Hi All,

may I check if there is any setting to make IAR to throw error/warning
whenever value contained in large sized variable(32 bit) is assingned
to small one(16bit) .

in one of our function we assign 32bit global variable to a local
variable of size 16 bit unknowingly and end up in truncated value in
local var which caused big havoc.

Thanks in advance.

Suresh








MISRA C lets you select which options to enable, and which to disable.



We use it sparingly, because we disagree on several of its rules.



Basically we choose what we want, anything that is reasonable.



The one option/rule you are interested in is a very valuable one, it did catch us with a mismatch, and saved us from hours of debugging.



It usually happens when you are dealing with multiple designers, and the piece of data in question crosses the boundary between someone who defined it with one attribute, and is being used by someone else with a different attribute.



You can disable all of them and just enable this one. It’s your choice.







From: m... [mailto:m...] On Behalf Of suresh

Sent: Sunday, August 12, 2012 1:02 AM

To: m...

Subject: Re: [msp430] IAR complier warning/error on size mismatch











Hi Hugo Brunert,



Thanks for the suggestion.

we don/t use MISRA C guide lines in our coding and this option is disabled in seetings.



I was trying to explore if there are any other way of specifying compilation options to check this kind of errors.



Thanks & rgds,

Suresh.







________________________________

From: Hugo Brunert >

To: m...

Sent: Saturday, August 11, 2012 6:30 PM

Subject: RE: [msp430] IAR complier warning/error on size mismatch









MISRA C will check that for you



Same for 16 into 8 or 32 into 8



From: mailto:msp430%40yahoogroups.com [mailto:mailto:msp430%40yahoogroups.com] On Behalf

Of sureshaps

Sent: Saturday, August 11, 2012 1:29 AM

To: mailto:msp430%40yahoogroups.com

Subject: [msp430] IAR complier warning/error on size mismatch



Hi All,



may I check if there is any setting to make IAR to throw error/warning

whenever value contained in large sized variable(32 bit) is assingned

to small one(16bit) .



in one of our function we assign 32bit global variable to a local

variable of size 16 bit unknowingly and end up in truncated value in

local var which caused big havoc.



Thanks in advance.



Suresh