<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title><![CDATA[MISRA Discussion Forums - 6.12 Expressions]]></title>
		<link>https://forum.misra.org.uk/</link>
		<description><![CDATA[MISRA Discussion Forums - https://forum.misra.org.uk]]></description>
		<pubDate>Thu, 05 Nov 2026 15:13:28 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Recommendations to resolve issue 12.4]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1158</link>
			<pubDate>Wed, 25 Feb 2015 22:16:57 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=2827">jbrookley</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1158</guid>
			<description><![CDATA[Hello,<br />
<br />
I had a question regarding rule 12.4 and realize I asked a similar question here:<br />
<br />
<a href="http://www.misra-c.com/forum/viewtopic.php?f=68&amp;t=1296" target="_blank" rel="noopener" class="mycode_url">http://www.misra-c.com/forum/viewtopic.php?f=68&amp;t=1296</a><br />
<br />
I didn't want to bump an old thread so I started a new one (hopefully, that's ok).  <br />
<br />
I received an error for rule 12-4 with the following section of code:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>if((CommandState!=7u)&amp;&amp;(CommandState!=8u)&amp;&amp;(CommandState!=9u)&amp;&amp;(CommandState!=10u)&amp;&amp;(CommandState!=11u)&amp;&amp;(commData==0x24u)) /* Please ignore the fact this is written inefficiently for now */<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CommandState = 0u;<br />
}</code></div></div><br />
I resolved this issue using the following section of code but I wasn't sure if this is the best way to handle the code or if it's recommended to handle it using a different technique:  <br />
<br />
[code]if(commData==0x24u)<br />
{<br />
	if(CommandState&gt;=7u)<br />
	{<br />
		if(CommandState]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
I had a question regarding rule 12.4 and realize I asked a similar question here:<br />
<br />
<a href="http://www.misra-c.com/forum/viewtopic.php?f=68&amp;t=1296" target="_blank" rel="noopener" class="mycode_url">http://www.misra-c.com/forum/viewtopic.php?f=68&amp;t=1296</a><br />
<br />
I didn't want to bump an old thread so I started a new one (hopefully, that's ok).  <br />
<br />
I received an error for rule 12-4 with the following section of code:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>if((CommandState!=7u)&amp;&amp;(CommandState!=8u)&amp;&amp;(CommandState!=9u)&amp;&amp;(CommandState!=10u)&amp;&amp;(CommandState!=11u)&amp;&amp;(commData==0x24u)) /* Please ignore the fact this is written inefficiently for now */<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CommandState = 0u;<br />
}</code></div></div><br />
I resolved this issue using the following section of code but I wasn't sure if this is the best way to handle the code or if it's recommended to handle it using a different technique:  <br />
<br />
[code]if(commData==0x24u)<br />
{<br />
	if(CommandState&gt;=7u)<br />
	{<br />
		if(CommandState]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Is it possible to right shift a signed variable? (12.7)]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=994</link>
			<pubDate>Tue, 29 Oct 2013 18:01:17 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=2827">jbrookley</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=994</guid>
			<description><![CDATA[Hello everyone,<br />
<br />
I have an application that I need to right shift a signed variable but it seems to be giving me some issues.  My initial line was:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>typedef unsigned char uchar8;<br />
typedef signed long slong32;<br />
<br />
slong32 Shifted Long;<br />
uchar8 NumBitsShift;<br />
<br />
ShiftedLong &gt;&gt;= NumBitsShift - 1u;</code></div></div><br />
Due to various MISRA C requirements, the code has morphed into this ridiculous block:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>typedef unsigned char uchar8;<br />
typedef signed char schar8;<br />
typedef signed long slong32;<br />
<br />
slong32 Shifted Long;<br />
uchar8 NumBitsShift;<br />
uchar8 tempchar = 0;<br />
slong32 templong = 0;<br />
<br />
tempchar = (uchar8)(NumBitsShift - 1u);<br />
<br />
if((tempchar&gt;=1u)&amp;&amp;(tempchar&gt; tempchar; /* MISRA C 12.7 Error here */<br />
}</code></div></div><br />
On the flagged line, I get the error "Underlying type of LHS operand bitwise operator is signed type: ShiftedLong".  I've tried fixing that by casting the tempchar as shown below:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>ShiftedLong = ShiftedLong &gt;&gt; (slong32)tempchar;</code></div></div><br />
I even tried to go completely over the top with plans to scale it back once I isolate the problem by doing this:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>ShiftedLong = (slong32)((slong32)ShiftedLong &gt;&gt; (slong32)tempchar);</code></div></div><br />
It appears, I am still having the same problem.  What it now appears, based on this, is that it is not possible to right shift a signed variable.  Is this true or is there a way around this? <br />
<br />
Any help you can give me would be appreciated.  Thanks!]]></description>
			<content:encoded><![CDATA[Hello everyone,<br />
<br />
I have an application that I need to right shift a signed variable but it seems to be giving me some issues.  My initial line was:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>typedef unsigned char uchar8;<br />
typedef signed long slong32;<br />
<br />
slong32 Shifted Long;<br />
uchar8 NumBitsShift;<br />
<br />
ShiftedLong &gt;&gt;= NumBitsShift - 1u;</code></div></div><br />
Due to various MISRA C requirements, the code has morphed into this ridiculous block:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>typedef unsigned char uchar8;<br />
typedef signed char schar8;<br />
typedef signed long slong32;<br />
<br />
slong32 Shifted Long;<br />
uchar8 NumBitsShift;<br />
uchar8 tempchar = 0;<br />
slong32 templong = 0;<br />
<br />
tempchar = (uchar8)(NumBitsShift - 1u);<br />
<br />
if((tempchar&gt;=1u)&amp;&amp;(tempchar&gt; tempchar; /* MISRA C 12.7 Error here */<br />
}</code></div></div><br />
On the flagged line, I get the error "Underlying type of LHS operand bitwise operator is signed type: ShiftedLong".  I've tried fixing that by casting the tempchar as shown below:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>ShiftedLong = ShiftedLong &gt;&gt; (slong32)tempchar;</code></div></div><br />
I even tried to go completely over the top with plans to scale it back once I isolate the problem by doing this:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>ShiftedLong = (slong32)((slong32)ShiftedLong &gt;&gt; (slong32)tempchar);</code></div></div><br />
It appears, I am still having the same problem.  What it now appears, based on this, is that it is not possible to right shift a signed variable.  Is this true or is there a way around this? <br />
<br />
Any help you can give me would be appreciated.  Thanks!]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Circular logic with rule 12.1]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=993</link>
			<pubDate>Mon, 28 Oct 2013 22:30:49 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=2827">jbrookley</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=993</guid>
			<description><![CDATA[Hello,<br />
<br />
I had a violation for rule 10-5 (the result of a]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
I had a violation for rule 10-5 (the result of a]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 12.4 - Do not use expressions with side effects]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=990</link>
			<pubDate>Thu, 24 Oct 2013 22:17:31 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=2827">jbrookley</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=990</guid>
			<description><![CDATA[Hello everyone,<br />
<br />
I am having a problem with rule 12.4 (Do not use expressions with side effects in the right hand operand of a logical '&amp;&amp;' operator).  My code is as follows:<br />
<br />
[code]if ((DualDAC == 0) &amp;&amp; (ADC1Flag ]]></description>
			<content:encoded><![CDATA[Hello everyone,<br />
<br />
I am having a problem with rule 12.4 (Do not use expressions with side effects in the right hand operand of a logical '&amp;&amp;' operator).  My code is as follows:<br />
<br />
[code]if ((DualDAC == 0) &amp;&amp; (ADC1Flag ]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[MISRA2004-12_7-3 - Underlying type of LHS operand]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=989</link>
			<pubDate>Thu, 17 Oct 2013 23:29:22 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=2827">jbrookley</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=989</guid>
			<description><![CDATA[I'm currently using Parasoft's C++ Test program and it's flagging the last line of the code below and I'm not seeing the error . . . "The error I'm getting is Underlying type of LHS operand of bitwise operator is signed type."  Below is the code:<br />
<br />
[code]typedef signed short sshort16;<br />
<br />
struct DACStruct<br />
{<br />
     sshort16 Off;<br />
};<br />
<br />
struct DACStruct DACData;<br />
<br />
DACData.Off = (sshort16)(EEPROM_BANK1[1]) + (((sshort16)(EEPROM_BANK1[0])) ]]></description>
			<content:encoded><![CDATA[I'm currently using Parasoft's C++ Test program and it's flagging the last line of the code below and I'm not seeing the error . . . "The error I'm getting is Underlying type of LHS operand of bitwise operator is signed type."  Below is the code:<br />
<br />
[code]typedef signed short sshort16;<br />
<br />
struct DACStruct<br />
{<br />
     sshort16 Off;<br />
};<br />
<br />
struct DACStruct DACData;<br />
<br />
DACData.Off = (sshort16)(EEPROM_BANK1[1]) + (((sshort16)(EEPROM_BANK1[0])) ]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[MISRA C - Rule 12.12]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=983</link>
			<pubDate>Wed, 18 Sep 2013 07:00:06 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=2833">Akhil</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=983</guid>
			<description><![CDATA[Just wanted to know if Line 3 in the following case is a violation for Rule 12.12 ...??<br />
<br />
1. int i; <br />
2. float f=2.1;<br />
3. i=(int)f &gt;&gt;2;     //Typecasting should actually take care of the bit implementation of floats<br />
<br />
Also, If its a violation to Rule 12.12..Does that mean all typecasts (from float to any other type) should also be considered as violationg this rule..?]]></description>
			<content:encoded><![CDATA[Just wanted to know if Line 3 in the following case is a violation for Rule 12.12 ...??<br />
<br />
1. int i; <br />
2. float f=2.1;<br />
3. i=(int)f &gt;&gt;2;     //Typecasting should actually take care of the bit implementation of floats<br />
<br />
Also, If its a violation to Rule 12.12..Does that mean all typecasts (from float to any other type) should also be considered as violationg this rule..?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 12.6 and functions taking/returning Boolean values.]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=880</link>
			<pubDate>Fri, 10 Feb 2012 09:22:32 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=611">zaffanella</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=880</guid>
			<description><![CDATA[The second part of Rule 12.6 says that:<br />
  <span style="font-style: italic;" class="mycode_i">"Expressions that are effectively Boolean should not be used as operands to operators other than ..."</span><br />
The list of the allowed operators has been corrected in TC1 to include <span style="font-weight: bold;" class="mycode_b">&amp;&amp;</span>, <span style="font-weight: bold;" class="mycode_b">||</span>, <span style="font-weight: bold;" class="mycode_b">!</span>, <span style="font-weight: bold;" class="mycode_b">=</span>, <span style="font-weight: bold;" class="mycode_b">==</span>, <span style="font-weight: bold;" class="mycode_b">!=</span> and <span style="font-weight: bold;" class="mycode_b">?:</span><br />
<br />
What about the function call operator <span style="font-weight: bold;" class="mycode_b">()</span> ?<br />
<br />
If a Boolean value (by enforcement or by construction) is used as an argument to a function having a parameter whose type is Boolean (by enforcement), are we violating Rule 12.6? For instance:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>typedef /* Boolean-by-enforcement type */ bool_t;<br />
void foo(bool_t b);<br />
<br />
void bar(int32_t a, int32_t b) {<br />
&nbsp;&nbsp;bool_t b = (a == b);<br />
&nbsp;&nbsp;foo(b); /* Non-compliant? */<br />
}</code></div></div><br />
A similar conversion problem exists when returning a Boolean value. In this case Rule 12.6 never applies (even though a Boolean value is being "abused") merely because, strictly speaking, the return statement is <span style="font-weight: bold;" class="mycode_b">not</span> an operator. For instance:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int32_t bar(int32_t a, int32_t b) {<br />
&nbsp;&nbsp;bool_t b = (a == b);<br />
&nbsp;&nbsp;return b; /* Compliant? */<br />
}</code></div></div><br />
Are the two examples above matching what was really meant by Rule 12.6 and TC1?]]></description>
			<content:encoded><![CDATA[The second part of Rule 12.6 says that:<br />
  <span style="font-style: italic;" class="mycode_i">"Expressions that are effectively Boolean should not be used as operands to operators other than ..."</span><br />
The list of the allowed operators has been corrected in TC1 to include <span style="font-weight: bold;" class="mycode_b">&amp;&amp;</span>, <span style="font-weight: bold;" class="mycode_b">||</span>, <span style="font-weight: bold;" class="mycode_b">!</span>, <span style="font-weight: bold;" class="mycode_b">=</span>, <span style="font-weight: bold;" class="mycode_b">==</span>, <span style="font-weight: bold;" class="mycode_b">!=</span> and <span style="font-weight: bold;" class="mycode_b">?:</span><br />
<br />
What about the function call operator <span style="font-weight: bold;" class="mycode_b">()</span> ?<br />
<br />
If a Boolean value (by enforcement or by construction) is used as an argument to a function having a parameter whose type is Boolean (by enforcement), are we violating Rule 12.6? For instance:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>typedef /* Boolean-by-enforcement type */ bool_t;<br />
void foo(bool_t b);<br />
<br />
void bar(int32_t a, int32_t b) {<br />
&nbsp;&nbsp;bool_t b = (a == b);<br />
&nbsp;&nbsp;foo(b); /* Non-compliant? */<br />
}</code></div></div><br />
A similar conversion problem exists when returning a Boolean value. In this case Rule 12.6 never applies (even though a Boolean value is being "abused") merely because, strictly speaking, the return statement is <span style="font-weight: bold;" class="mycode_b">not</span> an operator. For instance:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int32_t bar(int32_t a, int32_t b) {<br />
&nbsp;&nbsp;bool_t b = (a == b);<br />
&nbsp;&nbsp;return b; /* Compliant? */<br />
}</code></div></div><br />
Are the two examples above matching what was really meant by Rule 12.6 and TC1?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 12.6]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=785</link>
			<pubDate>Wed, 27 Oct 2010 15:55:39 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=780">azukich</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=785</guid>
			<description><![CDATA[Klocwork has been getting a number of complaints on our interpretation of rule 12.6.  For example:<br />
<br />
If(TRUE==TRUE) ...<br />
<br />
So if TRUE is a Boolean. â€œ==â€ is not of &amp;&amp;, ||, !. We report this as a violation, since the code should look like <br />
  If(TRUE) ...<br />
<br />
Many people have debated this.  Are we misunderstanding this?]]></description>
			<content:encoded><![CDATA[Klocwork has been getting a number of complaints on our interpretation of rule 12.6.  For example:<br />
<br />
If(TRUE==TRUE) ...<br />
<br />
So if TRUE is a Boolean. â€œ==â€ is not of &amp;&amp;, ||, !. We report this as a violation, since the code should look like <br />
  If(TRUE) ...<br />
<br />
Many people have debated this.  Are we misunderstanding this?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[12.4, reading volatile side effect]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=783</link>
			<pubDate>Wed, 13 Oct 2010 07:29:46 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=1262">jdp</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=783</guid>
			<description><![CDATA[Hi,<br />
<br />
It's the first Misra compliant project I'm involved in and I've some troubles to understand some rules. On in particular is rule 12.4. I've some expression like<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>if (xxx &amp;&amp; REGISTER)</code></div></div> where REGISTER is a deference to a volatile pointer (represents the content of a microcontroller register) declared as following: <br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#define REGISTER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*((uword volatile *) 0xEA2CU))</code></div></div><br />
The right and of &amp;&amp; doesn't comply to rule 12.4 because of the volatile access. I don't understand why reading a volatile content is not Misra compliant. The problem is that registers access are defined as volatile and I don't know how to overcome this to make my statement compliant.<br />
<br />
Thanks for your help.]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
It's the first Misra compliant project I'm involved in and I've some troubles to understand some rules. On in particular is rule 12.4. I've some expression like<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>if (xxx &amp;&amp; REGISTER)</code></div></div> where REGISTER is a deference to a volatile pointer (represents the content of a microcontroller register) declared as following: <br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#define REGISTER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*((uword volatile *) 0xEA2CU))</code></div></div><br />
The right and of &amp;&amp; doesn't comply to rule 12.4 because of the volatile access. I don't understand why reading a volatile content is not Misra compliant. The problem is that registers access are defined as volatile and I don't know how to overcome this to make my statement compliant.<br />
<br />
Thanks for your help.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 12.5: OR sequence without parentheses not compliant?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=774</link>
			<pubDate>Fri, 17 Sep 2010 07:51:28 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=885">pkrebs</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=774</guid>
			<description><![CDATA[Hello,<br />
<br />
I have a question regarding Rule 12.5: "The operands of a logical &amp;&amp; or || shall be primary-expressions."<br />
<br />
I often use constructs of the form "(condition1) || (condition2) || ... || (condition n)" to test for illegal values of a set of input parameters in functions (see example below), which should be compliant as far as I understand the rule text without the need of extra parentheses to group the conditions (parenthesised expression, sequence of only logical ||). However, my analysis tool (flexelint, v9.00e) complains about this construct ("non-primary expression"). Did I got something wrong about the definition of "primary expression" or is this a false positive?<br />
<br />
Thanks in advance for any answers.<br />
<br />
Example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>if ((start &gt;= end) || (start &gt; 7U) || (end &gt; 8U))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* raises rule violation */<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;/* do something */<br />
}<br />
else<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;/* do something different*/<br />
}<br />
<br />
<br />
if ((start &gt;= end) || ((start &gt; 7U) || (end &gt; 8U)))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* does not raise violation, note extra parentheses around second and third condition */<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;/* do something */<br />
}<br />
else<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;/* do something different*/<br />
}</code></div></div>]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
I have a question regarding Rule 12.5: "The operands of a logical &amp;&amp; or || shall be primary-expressions."<br />
<br />
I often use constructs of the form "(condition1) || (condition2) || ... || (condition n)" to test for illegal values of a set of input parameters in functions (see example below), which should be compliant as far as I understand the rule text without the need of extra parentheses to group the conditions (parenthesised expression, sequence of only logical ||). However, my analysis tool (flexelint, v9.00e) complains about this construct ("non-primary expression"). Did I got something wrong about the definition of "primary expression" or is this a false positive?<br />
<br />
Thanks in advance for any answers.<br />
<br />
Example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>if ((start &gt;= end) || (start &gt; 7U) || (end &gt; 8U))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* raises rule violation */<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;/* do something */<br />
}<br />
else<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;/* do something different*/<br />
}<br />
<br />
<br />
if ((start &gt;= end) || ((start &gt; 7U) || (end &gt; 8U)))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* does not raise violation, note extra parentheses around second and third condition */<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;/* do something */<br />
}<br />
else<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;/* do something different*/<br />
}</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[12.7 and narrowing signed integers]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=770</link>
			<pubDate>Tue, 31 Aug 2010 21:19:22 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=1192">tjotjos</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=770</guid>
			<description><![CDATA[I have a question concerning Rule 12.7: Bitwise operators shall not be applied to operands whose underlying type is signed.<br />
<br />
I need to transmit a 7-bit signed integer (values are restricted -64 - +63). My current method, shown below, seems to be inconsistent with 12.7.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int_8 s8a;<br />
uint_8 u8b;<br />
...<br />
u8b = s8a &amp; 0x7F;</code></div></div><br />
Is the following an acceptable solution, or a violation of 10.1? Do I need to use a deviation here for the 7-bit integer?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int_8 s8a;<br />
uint_8 u8b;<br />
...<br />
u8b = ((uint_8)s8a &amp; 0x7F;</code></div></div><br />
Thank you for your help!]]></description>
			<content:encoded><![CDATA[I have a question concerning Rule 12.7: Bitwise operators shall not be applied to operands whose underlying type is signed.<br />
<br />
I need to transmit a 7-bit signed integer (values are restricted -64 - +63). My current method, shown below, seems to be inconsistent with 12.7.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int_8 s8a;<br />
uint_8 u8b;<br />
...<br />
u8b = s8a &amp; 0x7F;</code></div></div><br />
Is the following an acceptable solution, or a violation of 10.1? Do I need to use a deviation here for the 7-bit integer?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int_8 s8a;<br />
uint_8 u8b;<br />
...<br />
u8b = ((uint_8)s8a &amp; 0x7F;</code></div></div><br />
Thank you for your help!]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Generalized Question about #12.6 and Preprocessor Directives]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=765</link>
			<pubDate>Tue, 17 Aug 2010 17:39:51 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=64">gs</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=765</guid>
			<description><![CDATA[Was advisory #12.6 intended to apply to preprocessor directives at all?  I only ask because the text does not specify one way or the other.]]></description>
			<content:encoded><![CDATA[Was advisory #12.6 intended to apply to preprocessor directives at all?  I only ask because the text does not specify one way or the other.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[12.6 for Preprocessor Directives?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=764</link>
			<pubDate>Thu, 05 Aug 2010 13:46:46 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=64">gs</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=764</guid>
			<description><![CDATA[Was 12.6 intended to prohibit the use of the '!' operator on such code as<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#if ! defined A<br />
#endif</code></div></div>?<br />
<br />
Could a case not be made the result of 'defined' is an "effectively Boolean Expression"?]]></description>
			<content:encoded><![CDATA[Was 12.6 intended to prohibit the use of the '!' operator on such code as<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#if ! defined A<br />
#endif</code></div></div>?<br />
<br />
Could a case not be made the result of 'defined' is an "effectively Boolean Expression"?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Was something missed for 12.6 about "?:"?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=735</link>
			<pubDate>Thu, 06 May 2010 15:25:32 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=64">gs</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=735</guid>
			<description><![CDATA[The wording of advisory #12.6 indicates expressions other than effectively boolean ones are permitted as the conditional argument to "?:".  Was this wording an oversight?  In three other circumstances, the guidelines insist on effectively boolean expressions and it seems unintuitive to not require such in this case as well.]]></description>
			<content:encoded><![CDATA[The wording of advisory #12.6 indicates expressions other than effectively boolean ones are permitted as the conditional argument to "?:".  Was this wording an oversight?  In three other circumstances, the guidelines insist on effectively boolean expressions and it seems unintuitive to not require such in this case as well.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rules 12.1 and 12.5 and unary operators]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=729</link>
			<pubDate>Thu, 22 Apr 2010 08:06:38 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=815">pmhill</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=729</guid>
			<description><![CDATA[It is said in rules 12.1 and 12.5 that 12.5 is a special case of 12.1.<br />
<br />
However, in rule 12.1, it is stated that no parentheses are required for the operand of a unary operator<br />
while in rule 12.5 it is said that the operands of the logical operators &amp;&amp; and || must be primary expressions;<br />
the latter is exemplified in 12.5 with the following example:<br />
<br />
if ( x &amp;&amp; ( !y ) ) /* make !y primary */<br />
<br />
So for rule 12.1, is something like:<br />
if ( x &amp;&amp; !y )<br />
...<br />
a violation?]]></description>
			<content:encoded><![CDATA[It is said in rules 12.1 and 12.5 that 12.5 is a special case of 12.1.<br />
<br />
However, in rule 12.1, it is stated that no parentheses are required for the operand of a unary operator<br />
while in rule 12.5 it is said that the operands of the logical operators &amp;&amp; and || must be primary expressions;<br />
the latter is exemplified in 12.5 with the following example:<br />
<br />
if ( x &amp;&amp; ( !y ) ) /* make !y primary */<br />
<br />
So for rule 12.1, is something like:<br />
if ( x &amp;&amp; !y )<br />
...<br />
a violation?]]></content:encoded>
		</item>
	</channel>
</rss>