<?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 - 8.2 Unused code]]></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:44 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[2.2 Dead code, 'operations' and casts]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1584</link>
			<pubDate>Thu, 21 Oct 2021 13:39:50 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5734">ACHart</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1584</guid>
			<description><![CDATA[Hi,<br />
<br />
I have a question regarding the meaning of 'Dead Code' within MISRA-2012.  My question is, I believe, somewhat similar to <a href="https://forum.misra.org.uk/thread-1266.html" target="_blank" rel="noopener" class="mycode_url">this thread</a>, but the contents of that thread appear to be missing such that I cannot determine what the exact question was, nor the answer.<br />
<br />
My questions are:<br />
<br />
1) What is an 'operation'?  'Dead code' is defined in terms of 'operations', but 'operation' is never defined in MISRA.<br />
<br />
2) Does an addition/subtraction of a constant 0 to a value<span style="color: #333333;" class="mycode_color"><span style="font-size: small;" class="mycode_size"><span style="font-family: Tahoma, Verdana, Arial, sans-serif;" class="mycode_font"> </span></span></span>(either literally or by macro) count as dead code?  This sometimes happens in the context of register offsets where the first offset is 0.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#define BASE_ADDR 0x80000000u<br />
#define CTRL_OFFSET 0x0u<br />
uint32_t a = BASE_ADDR + 0x0u; // Dead addition?<br />
uint32_t b = BASE_ADDR + CTRL_OFFSET; // Dead addition?</code></div></div><br />
3) Does a cast of a value to it's own type count as dead code?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>uint8_t a = (uint8_t)0u; // Dead cast? (Type of 0u is UTLR)<br />
uint8_t b = (uint8_t)a; // Dead cast? (Type of a is uint8_t)</code></div></div><br />
<br />
4) Does an explicit cast to a type for which implicit conversion is allowed count as dead code?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>uint8_t a = (uint8_t)0; // Dead cast? (Type of 0 is STLR, but assignment is permitted by exception)<br />
uint16_t b = (uint16_t)a; // Dead cast? (Conversion to wider type of same signedness is allowed implicitly)</code></div></div>]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
I have a question regarding the meaning of 'Dead Code' within MISRA-2012.  My question is, I believe, somewhat similar to <a href="https://forum.misra.org.uk/thread-1266.html" target="_blank" rel="noopener" class="mycode_url">this thread</a>, but the contents of that thread appear to be missing such that I cannot determine what the exact question was, nor the answer.<br />
<br />
My questions are:<br />
<br />
1) What is an 'operation'?  'Dead code' is defined in terms of 'operations', but 'operation' is never defined in MISRA.<br />
<br />
2) Does an addition/subtraction of a constant 0 to a value<span style="color: #333333;" class="mycode_color"><span style="font-size: small;" class="mycode_size"><span style="font-family: Tahoma, Verdana, Arial, sans-serif;" class="mycode_font"> </span></span></span>(either literally or by macro) count as dead code?  This sometimes happens in the context of register offsets where the first offset is 0.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#define BASE_ADDR 0x80000000u<br />
#define CTRL_OFFSET 0x0u<br />
uint32_t a = BASE_ADDR + 0x0u; // Dead addition?<br />
uint32_t b = BASE_ADDR + CTRL_OFFSET; // Dead addition?</code></div></div><br />
3) Does a cast of a value to it's own type count as dead code?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>uint8_t a = (uint8_t)0u; // Dead cast? (Type of 0u is UTLR)<br />
uint8_t b = (uint8_t)a; // Dead cast? (Type of a is uint8_t)</code></div></div><br />
<br />
4) Does an explicit cast to a type for which implicit conversion is allowed count as dead code?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>uint8_t a = (uint8_t)0; // Dead cast? (Type of 0 is STLR, but assignment is permitted by exception)<br />
uint16_t b = (uint16_t)a; // Dead cast? (Conversion to wider type of same signedness is allowed implicitly)</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 2.5 and unused macro parameter]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1533</link>
			<pubDate>Thu, 12 Mar 2020 15:04:00 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=4276">Mike Bailey</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1533</guid>
			<description><![CDATA[Rule 2.5 states "A project should not contain unused <span style="font-weight: bold;" class="mycode_b">macro declaration</span>".<br />
<br />
Forum post <a href="https://www.misra.org.uk/forum/viewtopic.php?f=216&amp;t=1571" target="_blank" rel="noopener" class="mycode_url">https://www.misra.org.uk/forum/viewtopic...216&amp;t=1571</a> acknowledges that Rule 2.5 should be "A project should not contain unused <span style="font-weight: bold;" class="mycode_b">macro definition</span>", however a change to "A project should not contain unused <span style="font-weight: bold;" class="mycode_b">macro identifier</span>" would cover both the original intent and also catch the following coding error without compromising rule decidability:<br />
[code]<br />
/* Macro containing coding error - macro parameter pin is unused */<br />
#define SET_PIN(pin, polarity)                        \ <br />
               ((GPIO-&gt;PIN[pin_number] &amp; ~PIN_Msk) |                  (polarity ]]></description>
			<content:encoded><![CDATA[Rule 2.5 states "A project should not contain unused <span style="font-weight: bold;" class="mycode_b">macro declaration</span>".<br />
<br />
Forum post <a href="https://www.misra.org.uk/forum/viewtopic.php?f=216&amp;t=1571" target="_blank" rel="noopener" class="mycode_url">https://www.misra.org.uk/forum/viewtopic...216&amp;t=1571</a> acknowledges that Rule 2.5 should be "A project should not contain unused <span style="font-weight: bold;" class="mycode_b">macro definition</span>", however a change to "A project should not contain unused <span style="font-weight: bold;" class="mycode_b">macro identifier</span>" would cover both the original intent and also catch the following coding error without compromising rule decidability:<br />
[code]<br />
/* Macro containing coding error - macro parameter pin is unused */<br />
#define SET_PIN(pin, polarity)                        \ <br />
               ((GPIO-&gt;PIN[pin_number] &amp; ~PIN_Msk) |                  (polarity ]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 2.1 : Checking for all possible error status - Is a deviation reasonable for this?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1456</link>
			<pubDate>Wed, 19 Sep 2018 17:30:54 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5134">guru72</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1456</guid>
			<description><![CDATA[Hello,<br />
 I have the following piece of code for which I get a MISRA Rule 2.1 error. I am considering a deviation for this -  All possible error status from a function call can be checked even if the function does not return all possible error statuses.  Can you please provide feedback on if this is a reasonable deviation? <br />
<br />
(Btw, this is my first post - please feel free to let me know if this is outside the scope here)<br />
<br />
Example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#include "stdafx.h"<br />
typedef enum ErrStatus {<br />
&nbsp;&nbsp;&nbsp;&nbsp;Success = 0,<br />
&nbsp;&nbsp;&nbsp;&nbsp;Err_1,<br />
&nbsp;&nbsp;&nbsp;&nbsp;Err_2<br />
} ErrStatus;<br />
<br />
ErrStatus f(int x) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (x &lt; 0) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return Err_1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return Success;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;int main()<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ErrStatus x = f(5);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch (x)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case Err_1:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("err 1"); break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case Err_2:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("err 2 "); break;&nbsp;&nbsp;/* Is this dead code ? */<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("Success"); break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}</code></div></div>]]></description>
			<content:encoded><![CDATA[Hello,<br />
 I have the following piece of code for which I get a MISRA Rule 2.1 error. I am considering a deviation for this -  All possible error status from a function call can be checked even if the function does not return all possible error statuses.  Can you please provide feedback on if this is a reasonable deviation? <br />
<br />
(Btw, this is my first post - please feel free to let me know if this is outside the scope here)<br />
<br />
Example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#include "stdafx.h"<br />
typedef enum ErrStatus {<br />
&nbsp;&nbsp;&nbsp;&nbsp;Success = 0,<br />
&nbsp;&nbsp;&nbsp;&nbsp;Err_1,<br />
&nbsp;&nbsp;&nbsp;&nbsp;Err_2<br />
} ErrStatus;<br />
<br />
ErrStatus f(int x) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (x &lt; 0) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return Err_1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return Success;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;int main()<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ErrStatus x = f(5);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch (x)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case Err_1:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("err 1"); break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case Err_2:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("err 2 "); break;&nbsp;&nbsp;/* Is this dead code ? */<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("Success"); break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 2.5 unsued macro definition]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1363</link>
			<pubDate>Fri, 08 Sep 2017 08:55:01 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=4772">sowiso</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1363</guid>
			<description><![CDATA[Hi,<br />
<br />
I have the following code:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>cfg.h:<br />
/* uncomment next line if the feature is needed for your project */<br />
/* #define activate_feature */<br />
<br />
-----<br />
feature.h:<br />
#ifdef activate_feature<br />
<br />
#ifdef protected_feature<br />
/* limited visibility stuff */<br />
[...]<br />
#endif /* protected feature */<br />
<br />
#endif /* activate feature */<br />
<br />
-----<br />
<br />
feature.c:<br />
#define protected_feature<br />
<br />
#include "cfg.h"<br />
#include "feature.h"<br />
<br />
#ifdef activate_feature<br />
[...]<br />
#endif /* activate feature */</code></div></div><br />
The code is part of a library which is used in various projects which shall be MISRA2012 compliant.<br />
Based on each project a different version of cfg.h is used which configures the project specific needs.<br />
In projects where activate_feature is not defined I always got a claim from my code checking tool that the macro protected_feature is not used.<br />
Is this really a violation of Rule 2.5 or is the code checker wrong? <br />
If it is a violation how to handle code where parts a selected by conditional compiling?]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
I have the following code:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>cfg.h:<br />
/* uncomment next line if the feature is needed for your project */<br />
/* #define activate_feature */<br />
<br />
-----<br />
feature.h:<br />
#ifdef activate_feature<br />
<br />
#ifdef protected_feature<br />
/* limited visibility stuff */<br />
[...]<br />
#endif /* protected feature */<br />
<br />
#endif /* activate feature */<br />
<br />
-----<br />
<br />
feature.c:<br />
#define protected_feature<br />
<br />
#include "cfg.h"<br />
#include "feature.h"<br />
<br />
#ifdef activate_feature<br />
[...]<br />
#endif /* activate feature */</code></div></div><br />
The code is part of a library which is used in various projects which shall be MISRA2012 compliant.<br />
Based on each project a different version of cfg.h is used which configures the project specific needs.<br />
In projects where activate_feature is not defined I always got a claim from my code checking tool that the macro protected_feature is not used.<br />
Is this really a violation of Rule 2.5 or is the code checker wrong? <br />
If it is a violation how to handle code where parts a selected by conditional compiling?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 2.2 dead code and empty function]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1353</link>
			<pubDate>Mon, 26 Jun 2017 05:59:59 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=4742">xiangke</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1353</guid>
			<description><![CDATA[An empty function is the dead code? for example:<br />
/*file1.c*/<br />
void vidNextStep(void)<br />
{<br />
<br />
}<br />
/*file2.c*/<br />
void test(void)<br />
{<br />
  vidNextStep();<br />
}<br />
I think an empty function is the dead code, because it shall be called, it means that it shall execute, but It shall not affect program behavior.<br />
Do it?]]></description>
			<content:encoded><![CDATA[An empty function is the dead code? for example:<br />
/*file1.c*/<br />
void vidNextStep(void)<br />
{<br />
<br />
}<br />
/*file2.c*/<br />
void test(void)<br />
{<br />
  vidNextStep();<br />
}<br />
I think an empty function is the dead code, because it shall be called, it means that it shall execute, but It shall not affect program behavior.<br />
Do it?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rul 2.5: Definition of a project and unused code]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1337</link>
			<pubDate>Tue, 18 Apr 2017 20:56:49 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=3240">sca2012</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1337</guid>
			<description><![CDATA[This questions would rather belong to a specific forum for discussions of glossary terms but I could not find the appropriate section. My original question deals with the definition of "Project". I'll use example of unused code, but this issue could also be discussed in a context of other rules.<br />
<br />
Let's say, I build an executable that makes use of a library, whose headers, say, contain a certain macro definition. This macro is not used anywhere in the source code of the executable directly, but it is used somewhere inside the library.<br />
<br />
Is this situation compliant with Rule 2.5?<br />
<br />
What if this library is actually a third party library whose source code is not available? Should the library itself be MISRA-compliant for the using code to be compliant (and thus definition of a "project" should also contain libraries and not only an executables)?]]></description>
			<content:encoded><![CDATA[This questions would rather belong to a specific forum for discussions of glossary terms but I could not find the appropriate section. My original question deals with the definition of "Project". I'll use example of unused code, but this issue could also be discussed in a context of other rules.<br />
<br />
Let's say, I build an executable that makes use of a library, whose headers, say, contain a certain macro definition. This macro is not used anywhere in the source code of the executable directly, but it is used somewhere inside the library.<br />
<br />
Is this situation compliant with Rule 2.5?<br />
<br />
What if this library is actually a third party library whose source code is not available? Should the library itself be MISRA-compliant for the using code to be compliant (and thus definition of a "project" should also contain libraries and not only an executables)?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 2.5 vs. include guards]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1317</link>
			<pubDate>Mon, 27 Feb 2017 11:54:10 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=4672">sg2</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1317</guid>
			<description><![CDATA[Hi.<br />
It is not completely clear what is meant by use of a macro in Rule 2.5. There is definition of a use of an expression in the Glossary, but not of a macro.<br />
If taken literally, rule 2.5 means that standard include guards are forbidden:<br />
<br />
#ifndef HEADER_H<br />
#define HEADER_H // Not used unless another #ifndef is encountered somewhere inside<br />
...<br />
#endif]]></description>
			<content:encoded><![CDATA[Hi.<br />
It is not completely clear what is meant by use of a macro in Rule 2.5. There is definition of a use of an expression in the Glossary, but not of a macro.<br />
If taken literally, rule 2.5 means that standard include guards are forbidden:<br />
<br />
#ifndef HEADER_H<br />
#define HEADER_H // Not used unless another #ifndef is encountered somewhere inside<br />
...<br />
#endif]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Possible inaccurate example?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1293</link>
			<pubDate>Thu, 17 Nov 2016 17:34:39 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=2627">andream</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1293</guid>
			<description><![CDATA[The following is the example reported for Rule 2.2 (dead code):<br />
<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>In this example, it is assumed that the object pointed to by p is used in other functions.</blockquote>
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>extern volatile uint16_t v;<br />
extern char *p;<br />
<br />
void f (void )&nbsp;&nbsp;{<br />
&nbsp;&nbsp; uint16_t x;<br />
&nbsp;&nbsp; (void) v;&nbsp;&nbsp;/* Compliant - v is accessed for its side effect * and the cast&nbsp;&nbsp;to void is permitted by exception */<br />
&nbsp;&nbsp; (int32_t) v; /* Non-compliant - the cast operator is dead */<br />
&nbsp;&nbsp; v &gt;&gt; 3;&nbsp;&nbsp;&nbsp;&nbsp; /* Non-compliant - the &gt;&gt; operator is dead */<br />
&nbsp;&nbsp; x = 3;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Non-compliant - the = operator is dead * - x is not subsequently read */<br />
&nbsp;&nbsp; *p++;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Non-compliant - result of * operator is not used */<br />
&nbsp;&nbsp; (*p)++;&nbsp;&nbsp;&nbsp;&nbsp; /* Compliant - *p is incremented */<br />
}</code></div></div><br />
I'm not sure that last but one statement represents a non-compliance. In fact, the expression *p++ is treated as *(p++), as the precedence of postfix ++ is higher than *. Indeed the result of * operator is not used, but p value results permanently increased, and p is a global variable. How can be stated that it is not compliant, alias dead code, i.e. "<span style="font-style: italic;" class="mycode_i">...whose removal would not affect program behaviour</span>"?]]></description>
			<content:encoded><![CDATA[The following is the example reported for Rule 2.2 (dead code):<br />
<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>In this example, it is assumed that the object pointed to by p is used in other functions.</blockquote>
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>extern volatile uint16_t v;<br />
extern char *p;<br />
<br />
void f (void )&nbsp;&nbsp;{<br />
&nbsp;&nbsp; uint16_t x;<br />
&nbsp;&nbsp; (void) v;&nbsp;&nbsp;/* Compliant - v is accessed for its side effect * and the cast&nbsp;&nbsp;to void is permitted by exception */<br />
&nbsp;&nbsp; (int32_t) v; /* Non-compliant - the cast operator is dead */<br />
&nbsp;&nbsp; v &gt;&gt; 3;&nbsp;&nbsp;&nbsp;&nbsp; /* Non-compliant - the &gt;&gt; operator is dead */<br />
&nbsp;&nbsp; x = 3;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Non-compliant - the = operator is dead * - x is not subsequently read */<br />
&nbsp;&nbsp; *p++;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Non-compliant - result of * operator is not used */<br />
&nbsp;&nbsp; (*p)++;&nbsp;&nbsp;&nbsp;&nbsp; /* Compliant - *p is incremented */<br />
}</code></div></div><br />
I'm not sure that last but one statement represents a non-compliance. In fact, the expression *p++ is treated as *(p++), as the precedence of postfix ++ is higher than *. Indeed the result of * operator is not used, but p value results permanently increased, and p is a global variable. How can be stated that it is not compliant, alias dead code, i.e. "<span style="font-style: italic;" class="mycode_i">...whose removal would not affect program behaviour</span>"?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 2.2 - dead code]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1266</link>
			<pubDate>Mon, 25 Jul 2016 13:16:44 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=4245">delta_controls</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1266</guid>
			<description><![CDATA[Does the following code example violate Rule 2.2, due to the left shift?<br />
<br />
[code]#define BITSET(reg, bit)	((reg) |= (uint8_t)(1u ]]></description>
			<content:encoded><![CDATA[Does the following code example violate Rule 2.2, due to the left shift?<br />
<br />
[code]#define BITSET(reg, bit)	((reg) |= (uint8_t)(1u ]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[declaration or definition]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1260</link>
			<pubDate>Thu, 23 Jun 2016 00:38:41 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=3977">Motozo Mario Ikeda</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1260</guid>
			<description><![CDATA[Rule 2.3 mentions "type declaration".<br />
Rule 2.5 mentions "macro declaration".<br />
<br />
But I think the type should not be declared but defined by "typedef".<br />
I also think the macro should not be decalred but defined by "#define".<br />
<br />
MISRA Study Group in Japan is confused when translating the guidelines.<br />
<br />
Thank you]]></description>
			<content:encoded><![CDATA[Rule 2.3 mentions "type declaration".<br />
Rule 2.5 mentions "macro declaration".<br />
<br />
But I think the type should not be declared but defined by "typedef".<br />
I also think the macro should not be decalred but defined by "#define".<br />
<br />
MISRA Study Group in Japan is confused when translating the guidelines.<br />
<br />
Thank you]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 2.4 and tag used in typedef]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1210</link>
			<pubDate>Fri, 30 Oct 2015 09:05:45 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=1443">lovewar</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1210</guid>
			<description><![CDATA[Would the following examples be compliant with rule #2.4?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>typedef struct cood cood_t;<br />
 struct cood {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// here,&nbsp;&nbsp;is the tag "cood" compliant?<br />
&nbsp;&nbsp;&nbsp;&nbsp;uint8_t&nbsp;&nbsp;id;<br />
 };</code></div></div>]]></description>
			<content:encoded><![CDATA[Would the following examples be compliant with rule #2.4?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>typedef struct cood cood_t;<br />
 struct cood {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// here,&nbsp;&nbsp;is the tag "cood" compliant?<br />
&nbsp;&nbsp;&nbsp;&nbsp;uint8_t&nbsp;&nbsp;id;<br />
 };</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 2.4 and forward declarations]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1175</link>
			<pubDate>Tue, 21 Apr 2015 22:08:44 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=2549">michael.metivier</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1175</guid>
			<description><![CDATA[Would the use of tags for forward declarations be considered a failure of this rule, if used such as<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct test;<br />
typedef struct test test_T;<br />
<br />
typedef bool (*Callback_T)(test_T const * p_test);<br />
<br />
struct test<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;uint32_t var;<br />
&nbsp;&nbsp;&nbsp;&nbsp;Callback_T callback;<br />
};</code></div></div>For consistency in type usage, I would prefer to utilize the typedef whenever referring to this structure, including in the callback definition, but this leads our analysis tools to flag that "test" is only used in the typedef.]]></description>
			<content:encoded><![CDATA[Would the use of tags for forward declarations be considered a failure of this rule, if used such as<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct test;<br />
typedef struct test test_T;<br />
<br />
typedef bool (*Callback_T)(test_T const * p_test);<br />
<br />
struct test<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;uint32_t var;<br />
&nbsp;&nbsp;&nbsp;&nbsp;Callback_T callback;<br />
};</code></div></div>For consistency in type usage, I would prefer to utilize the typedef whenever referring to this structure, including in the callback definition, but this leads our analysis tools to flag that "test" is only used in the typedef.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[else statement about Rule2.1]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1124</link>
			<pubDate>Tue, 28 Oct 2014 06:57:52 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=3139">KumikoItoh</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1124</guid>
			<description><![CDATA[I have a question about Rule2.1.<br />
 <br />
Are these samples  correct?<br />
The else statement is null statement or not.<br />
<br />
sample_1<br />
if ( a= 5 ) {<br />
 y=3;<br />
}else{<br />
 y=0;  /* not compliant */<br />
}<br />
<br />
sample_2<br />
if ( a= 5 ) {<br />
 y=3;<br />
}else{<br />
 ;  /* compliant */<br />
}<br />
<br />
I think if the else statement is null statement the code is reachable.<br />
Is is correct?<br />
<br />
And how about is default  label?<br />
<br />
In case all case is coded,if default label has null statement , the code is reachable.<br />
Is it correct? <br />
<br />
Please teach me.<br />
<br />
Regards]]></description>
			<content:encoded><![CDATA[I have a question about Rule2.1.<br />
 <br />
Are these samples  correct?<br />
The else statement is null statement or not.<br />
<br />
sample_1<br />
if ( a= 5 ) {<br />
 y=3;<br />
}else{<br />
 y=0;  /* not compliant */<br />
}<br />
<br />
sample_2<br />
if ( a= 5 ) {<br />
 y=3;<br />
}else{<br />
 ;  /* compliant */<br />
}<br />
<br />
I think if the else statement is null statement the code is reachable.<br />
Is is correct?<br />
<br />
And how about is default  label?<br />
<br />
In case all case is coded,if default label has null statement , the code is reachable.<br />
Is it correct? <br />
<br />
Please teach me.<br />
<br />
Regards]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 2.5 Does #undef count as a "use"]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1114</link>
			<pubDate>Thu, 09 Oct 2014 08:31:50 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=196">misra-c</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1114</guid>
			<description><![CDATA[Rule 2.5  Is #undef considered a â€œuseâ€ of a macroâ€?<br />
  For example<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#define M1 This<br />
&nbsp;&nbsp; #define M2 That<br />
&nbsp;&nbsp; #undef M1<br />
&nbsp;&nbsp; use( M2 );</code></div></div>Is 'M1' unused and therefore violate rule 2.5, or does the #undef count as a use of M1?]]></description>
			<content:encoded><![CDATA[Rule 2.5  Is #undef considered a â€œuseâ€ of a macroâ€?<br />
  For example<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#define M1 This<br />
&nbsp;&nbsp; #define M2 That<br />
&nbsp;&nbsp; #undef M1<br />
&nbsp;&nbsp; use( M2 );</code></div></div>Is 'M1' unused and therefore violate rule 2.5, or does the #undef count as a use of M1?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Is a function parameter â€œusedâ€ if cast to void?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1113</link>
			<pubDate>Thu, 09 Oct 2014 08:29:19 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=196">misra-c</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1113</guid>
			<description><![CDATA[Does the following violate rule 2.7 (There should be no unused parameters in functions)?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>void fn ( int32_t param )<br />
{<br />
&nbsp;&nbsp; ( void )param;<br />
}</code></div></div>]]></description>
			<content:encoded><![CDATA[Does the following violate rule 2.7 (There should be no unused parameters in functions)?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>void fn ( int32_t param )<br />
{<br />
&nbsp;&nbsp; ( void )param;<br />
}</code></div></div>]]></content:encoded>
		</item>
	</channel>
</rss>