<?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 - All Forums]]></title>
		<link>https://forum.misra.org.uk/</link>
		<description><![CDATA[MISRA Discussion Forums - https://forum.misra.org.uk]]></description>
		<pubDate>Thu, 05 Nov 2026 13:56:47 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Rule 0.1.1 Example f4]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1787</link>
			<pubDate>Wed, 30 Sep 2026 12:05:20 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5614">cgpzs</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1787</guid>
			<description><![CDATA[Hi,<br />
<br />
In MISRA C++:2023 TC1 Rule 0.1.1, the comment about example f4() says:<br />
<br />
<span style="font-style: italic;" class="mycode_i">As j is only incremented, no value is overwritten without first being read. Additionally, all iterations</span><br />
<span style="font-style: italic;" class="mycode_i">of the loop other than the first observe j after it has been incremented, meaning the write in the</span><br />
<span style="font-style: italic;" class="mycode_i">increment is necessary.</span><br />
<br />
This is not technically correct: the *last* iteration of the loop will *not* observe the value of j after it has been incremented. Do you consider that the last increment of "j" violates Rule 0.1.1?<br />
<br />
What about this?<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>template &lt;int n&gt;<br />
void f()<br />
{<br />
  int j = 0;<br />
  for (int i = 0; i &lt; n; ++i)<br />
  {<br />
    use(j);<br />
    j++;  // Violates Rule 0.1.1 for n == 1?<br />
  }<br />
}</code></div></div><br />
The above code never uses the incremented value of "j" for a template instantiation with "n = 1". Is that a violation of Rule 0.1.1?<br />
<hr class="mycode_hr" />
I see now that this exact use case was explicitly allowed in the original MISRA C++:2023 document, but removed in the TC1.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Within a loop, a value may be written to an object with the intent that it will be observed during the<br />
next iteration, meaning that the value written on the last iteration may never be observed. Whilst it is<br />
possible to restructure the loop to avoid this behaviour, there is a risk that the resulting code may be<br />
of lower quality (less clear, for example). This rule therefore considers observation during any iteration<br />
to apply to all values written to such an object, including a value written during the last iteration of a<br />
loop that is not actually observed — see example f3, below.</code></div></div>]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
In MISRA C++:2023 TC1 Rule 0.1.1, the comment about example f4() says:<br />
<br />
<span style="font-style: italic;" class="mycode_i">As j is only incremented, no value is overwritten without first being read. Additionally, all iterations</span><br />
<span style="font-style: italic;" class="mycode_i">of the loop other than the first observe j after it has been incremented, meaning the write in the</span><br />
<span style="font-style: italic;" class="mycode_i">increment is necessary.</span><br />
<br />
This is not technically correct: the *last* iteration of the loop will *not* observe the value of j after it has been incremented. Do you consider that the last increment of "j" violates Rule 0.1.1?<br />
<br />
What about this?<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>template &lt;int n&gt;<br />
void f()<br />
{<br />
  int j = 0;<br />
  for (int i = 0; i &lt; n; ++i)<br />
  {<br />
    use(j);<br />
    j++;  // Violates Rule 0.1.1 for n == 1?<br />
  }<br />
}</code></div></div><br />
The above code never uses the incremented value of "j" for a template instantiation with "n = 1". Is that a violation of Rule 0.1.1?<br />
<hr class="mycode_hr" />
I see now that this exact use case was explicitly allowed in the original MISRA C++:2023 document, but removed in the TC1.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Within a loop, a value may be written to an object with the intent that it will be observed during the<br />
next iteration, meaning that the value written on the last iteration may never be observed. Whilst it is<br />
possible to restructure the loop to avoid this behaviour, there is a risk that the resulting code may be<br />
of lower quality (less clear, for example). This rule therefore considers observation during any iteration<br />
to apply to all values written to such an object, including a value written during the last iteration of a<br />
loop that is not actually observed — see example f3, below.</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6-2-2 Usage of std::fpclassify]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1786</link>
			<pubDate>Mon, 21 Sep 2026 08:37:41 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5614">cgpzs</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1786</guid>
			<description><![CDATA[Hi,<br />
<br />
We have seen a creative way to work around MISRA Rule 6-2-2:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>float x = ...;<br />
float y = ...;<br />
<br />
if (x == 0.F)&nbsp;&nbsp;// non-compliant<br />
if (x == y)&nbsp;&nbsp;&nbsp;&nbsp;// non-compliant<br />
<br />
if (std::fpclassify(x)&nbsp;&nbsp;&nbsp;&nbsp; == FP_ZERO)&nbsp;&nbsp;// compliant?<br />
if (std::fpclassify(x - y) == FP_ZERO)&nbsp;&nbsp;// compliant?</code></div></div><br />
Would the last 2 examples be compliant with the rule?<br />
<br />
We argue that this is an <span style="font-weight: bold;" class="mycode_b">indirect</span> test for equality and thus non-compliant.]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
We have seen a creative way to work around MISRA Rule 6-2-2:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>float x = ...;<br />
float y = ...;<br />
<br />
if (x == 0.F)&nbsp;&nbsp;// non-compliant<br />
if (x == y)&nbsp;&nbsp;&nbsp;&nbsp;// non-compliant<br />
<br />
if (std::fpclassify(x)&nbsp;&nbsp;&nbsp;&nbsp; == FP_ZERO)&nbsp;&nbsp;// compliant?<br />
if (std::fpclassify(x - y) == FP_ZERO)&nbsp;&nbsp;// compliant?</code></div></div><br />
Would the last 2 examples be compliant with the rule?<br />
<br />
We argue that this is an <span style="font-weight: bold;" class="mycode_b">indirect</span> test for equality and thus non-compliant.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[M5-0-4 switch over unscoped enum without fixed underlying type]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1785</link>
			<pubDate>Wed, 16 Sep 2026 11:08:53 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5614">cgpzs</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1785</guid>
			<description><![CDATA[Hi,<br />
<br />
Our static analyzer is flagging this code:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>// third_party.h<br />
typedef enum <br />
{<br />
  FOO_A,<br />
  FOO_B<br />
} Foo;<br />
<br />
// main.cpp<br />
#include &lt;third_party.h&gt;<br />
<br />
int get(Foo x)<br />
{<br />
  switch(x)            // Non-compliant with M5-0-4 ?<br />
  {<br />
    case FOO_A:        // Non-compliant with M5-0-4 ?<br />
      return 123;<br />
    case FOO_B:        // Non-compliant with M5-0-4 ?<br />
      return 321;<br />
  }<br />
  return -1;<br />
}</code></div></div><br />
The rationale from the supplier is:<br />
<ul class="mycode_list"><li>"Foo" is an unscoped enum without fixed underlying type.<br />
</li>
<li>Thus, its underlying type is implementation-defined.<br />
</li>
<li>On this implementation, the actual type is "unsigned int".<br />
</li>
<li>The line with "switch(x)" performs an integral promotion of "x" to "int", <span style="font-weight: bold;" class="mycode_b">thus changing the signedness</span> from "unsigned int" to "int".<br />
</li>
<li>Similarly, the "case FOO_*" lines also perform an integral promotion to "int".<br />
</li>
<li>This change in signedness is a violation of M5-0-4.<br />
</li>
</ul>
<br />
We argue however that the code is perfectly safe and idiomatic, the Standard guarantees that the conversion is made to an integer able to hold all the values of the enumerator, so it's impossible for data loss to occur.<br />
<br />
What is your opinion, is M5-0-4 truly applicable in this case?<br />
<br />
Thanks!]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
Our static analyzer is flagging this code:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>// third_party.h<br />
typedef enum <br />
{<br />
  FOO_A,<br />
  FOO_B<br />
} Foo;<br />
<br />
// main.cpp<br />
#include &lt;third_party.h&gt;<br />
<br />
int get(Foo x)<br />
{<br />
  switch(x)            // Non-compliant with M5-0-4 ?<br />
  {<br />
    case FOO_A:        // Non-compliant with M5-0-4 ?<br />
      return 123;<br />
    case FOO_B:        // Non-compliant with M5-0-4 ?<br />
      return 321;<br />
  }<br />
  return -1;<br />
}</code></div></div><br />
The rationale from the supplier is:<br />
<ul class="mycode_list"><li>"Foo" is an unscoped enum without fixed underlying type.<br />
</li>
<li>Thus, its underlying type is implementation-defined.<br />
</li>
<li>On this implementation, the actual type is "unsigned int".<br />
</li>
<li>The line with "switch(x)" performs an integral promotion of "x" to "int", <span style="font-weight: bold;" class="mycode_b">thus changing the signedness</span> from "unsigned int" to "int".<br />
</li>
<li>Similarly, the "case FOO_*" lines also perform an integral promotion to "int".<br />
</li>
<li>This change in signedness is a violation of M5-0-4.<br />
</li>
</ul>
<br />
We argue however that the code is perfectly safe and idiomatic, the Standard guarantees that the conversion is made to an integer able to hold all the values of the enumerator, so it's impossible for data loss to occur.<br />
<br />
What is your opinion, is M5-0-4 truly applicable in this case?<br />
<br />
Thanks!]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 8-4-4 Exception for stream manipulators?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1782</link>
			<pubDate>Mon, 07 Sep 2026 08:22:54 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5614">cgpzs</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1782</guid>
			<description><![CDATA[Hi,<br />
<br />
Does Rule 8-4-4 imply that we have to write code like this? I do not see any exception for stream manipulators. Our static analyzer is flagging this case.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>std::cout &lt;&lt; "Hello World" &lt;&lt; &amp;std::endl;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;^</code></div></div>]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
Does Rule 8-4-4 imply that we have to write code like this? I do not see any exception for stream manipulators. Our static analyzer is flagging this case.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>std::cout &lt;&lt; "Hello World" &lt;&lt; &amp;std::endl;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;^</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[13.3 Should side effects be allowed in comma expressions?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1781</link>
			<pubDate>Mon, 31 Aug 2026 12:52:23 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6753">Loïc</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1781</guid>
			<description><![CDATA[In a comma expression (which is discouraged by another advisory rule, 12.3, but could still be used), there is a clear separation in term of execution between what comes before and what comes after the comma. Therefore, I think the rationale is not very strong in this case.<br />
<br />
What would you think of relaxing 13.3 and making this example compliant (it would still be non-compliant with 12.3):<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int f(int n, int*dest) {<br />
    for (int i = 0 ; i&lt;10 ; ++i, ++dest) { // Currently non-compliant<br />
        *dest = i*i;<br />
    }<br />
}</code></div></div>]]></description>
			<content:encoded><![CDATA[In a comma expression (which is discouraged by another advisory rule, 12.3, but could still be used), there is a clear separation in term of execution between what comes before and what comes after the comma. Therefore, I think the rationale is not very strong in this case.<br />
<br />
What would you think of relaxing 13.3 and making this example compliant (it would still be non-compliant with 12.3):<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int f(int n, int*dest) {<br />
    for (int i = 0 ; i&lt;10 ; ++i, ++dest) { // Currently non-compliant<br />
        *dest = i*i;<br />
    }<br />
}</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[13.3 What not being evaluated means?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1780</link>
			<pubDate>Fri, 28 Aug 2026 16:19:16 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6753">Loïc</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1780</guid>
			<description><![CDATA[Hi there,<br />
<br />
Rule 13.3 says:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>All sub-expressions of the <span style="font-style: italic;" class="mycode_i">full expression</span> are treated as if they were evaluated for the purposes of this rule, even if specified as not being evaluated by the C Standard.</blockquote>
<br />
I understand what it makes sense in the context for instance of the conditional operator, but I wanted to check it this applies the sub-expressions that can be determined as never evaluated because they are in non-evaluated operands.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int f(int a) {<br />
    volatile int i;<br />
    return ++a + sizeof(i); <br />
}</code></div></div> <br />
Accessing the volatile variable i is a persistent side effect, but since this access happens as part of a sizeof operand, that is not evaluated, no actual access to the volatile actually happens.<br />
<br />
Would it make sense to update this rule (and several other that use similar wording) to separate the undecidable case of infeasible paths from the very decidable case of non-evaluated expressions?<br />
<br />
FYI, in similar cases, MISRA C++ uses wording such as " even if they occur in an infeasible path" instead of "even if specified as not being evaluated".]]></description>
			<content:encoded><![CDATA[Hi there,<br />
<br />
Rule 13.3 says:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>All sub-expressions of the <span style="font-style: italic;" class="mycode_i">full expression</span> are treated as if they were evaluated for the purposes of this rule, even if specified as not being evaluated by the C Standard.</blockquote>
<br />
I understand what it makes sense in the context for instance of the conditional operator, but I wanted to check it this applies the sub-expressions that can be determined as never evaluated because they are in non-evaluated operands.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int f(int a) {<br />
    volatile int i;<br />
    return ++a + sizeof(i); <br />
}</code></div></div> <br />
Accessing the volatile variable i is a persistent side effect, but since this access happens as part of a sizeof operand, that is not evaluated, no actual access to the volatile actually happens.<br />
<br />
Would it make sense to update this rule (and several other that use similar wording) to separate the undecidable case of infeasible paths from the very decidable case of non-evaluated expressions?<br />
<br />
FYI, in similar cases, MISRA C++ uses wording such as " even if they occur in an infeasible path" instead of "even if specified as not being evaluated".]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Clarification Rule 0.2.1]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1779</link>
			<pubDate>Thu, 27 Aug 2026 11:32:03 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5889">hahn</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1779</guid>
			<description><![CDATA[Hi,<br />
<br />
I have a question regarding rule 0.2.1 on the following code:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>namespace {<br />
<br />
struct Base {<br />
  Base() {<br />
    // do resource management<br />
  }<br />
};<br />
<br />
struct Derived : public Base {<br />
  // has implicit default constructor that calls user-provided Base()<br />
};<br />
<br />
Base b; // (1) compliant<br />
Derived d; // (2) compliant or non-compliant for rule 0.2.1 ?<br />
<br />
}</code></div></div><br />
Case (1) is clearly compliant as b has class type Base and Base has a user-provided constructor.<br />
Case (2) is unclear, as the default constructor of Derived is not user-provided, if I understand the C++ standard correctly, as the user does not declare it at all.<br />
Still case (2) seems fine and in line with the rule's rationale.<br />
<br />
It would be great to get a clarification whether case (2) is considered compliant or not, and if compliant, what the intended definition of "use" should be.<br />
Thanks a lot!]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
I have a question regarding rule 0.2.1 on the following code:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>namespace {<br />
<br />
struct Base {<br />
  Base() {<br />
    // do resource management<br />
  }<br />
};<br />
<br />
struct Derived : public Base {<br />
  // has implicit default constructor that calls user-provided Base()<br />
};<br />
<br />
Base b; // (1) compliant<br />
Derived d; // (2) compliant or non-compliant for rule 0.2.1 ?<br />
<br />
}</code></div></div><br />
Case (1) is clearly compliant as b has class type Base and Base has a user-provided constructor.<br />
Case (2) is unclear, as the default constructor of Derived is not user-provided, if I understand the C++ standard correctly, as the user does not declare it at all.<br />
Still case (2) seems fine and in line with the rule's rationale.<br />
<br />
It would be great to get a clarification whether case (2) is considered compliant or not, and if compliant, what the intended definition of "use" should be.<br />
Thanks a lot!]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[20.12 Does the stringification really matter?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1778</link>
			<pubDate>Tue, 07 Jul 2026 09:59:02 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6753">Loïc</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1778</guid>
			<description><![CDATA[Hello,<br />
<br />
While looking at violations of 20.12 <span style="font-style: italic;" class="mycode_i">A macro parameter used as an operand to the "#" or "##" operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators</span>, I discovered that most of them were of the form:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>assert(value &lt; LIMIT)</code></div></div><br />
Indeed, the macro parameter of <span style="font-weight: bold;" class="mycode_b">assert</span> is typically stringified, and in that case it contains the macro <span style="font-weight: bold;" class="mycode_b">LIMIT </span>that is itself subject to further replacement.<br />
<br />
However, I don't see the safety case for this violation. The fact that the unexpended version of the macro will appear in the string is exactly what is needed.<br />
<br />
I agree that with token pasting (<span style="font-weight: bold;" class="mycode_b">##</span>), this situation could lead to hard to understand code, but not with stringification.<br />
<br />
FWIW, I discussed this with MISRA C++ (that contains the same rule), and the sentiment of the group was that the rule should be updated to remove the stringification part.<br />
<br />
<br />
What do you think?]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
While looking at violations of 20.12 <span style="font-style: italic;" class="mycode_i">A macro parameter used as an operand to the "#" or "##" operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators</span>, I discovered that most of them were of the form:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>assert(value &lt; LIMIT)</code></div></div><br />
Indeed, the macro parameter of <span style="font-weight: bold;" class="mycode_b">assert</span> is typically stringified, and in that case it contains the macro <span style="font-weight: bold;" class="mycode_b">LIMIT </span>that is itself subject to further replacement.<br />
<br />
However, I don't see the safety case for this violation. The fact that the unexpended version of the macro will appear in the string is exactly what is needed.<br />
<br />
I agree that with token pasting (<span style="font-weight: bold;" class="mycode_b">##</span>), this situation could lead to hard to understand code, but not with stringification.<br />
<br />
FWIW, I discussed this with MISRA C++ (that contains the same rule), and the sentiment of the group was that the rule should be updated to remove the stringification part.<br />
<br />
<br />
What do you think?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Does rule A2-10-5 apply to reusing an external identifier as a member identifier?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1777</link>
			<pubDate>Mon, 06 Jul 2026 12:23:34 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5807">mstaron</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1777</guid>
			<description><![CDATA[Rule A2-10-5 states: Regardless of scope, no identifier with static storage duration should be reused across any source files in the project. Are cases where an identifier is reused as a member non-compliant with this rule? In particular, the case where an operator function is defined as a global and a member function.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct S<br />
{<br />
&nbsp;&nbsp;void operator&lt;&lt;(S&amp;) {}<br />
&nbsp;&nbsp;void f1(int par) {}<br />
};<br />
<br />
namespace N<br />
{<br />
&nbsp;&nbsp;void operator&lt;&lt;(int i, S&amp;) {}&nbsp;&nbsp;// Is compliant or non-compliant?<br />
&nbsp;&nbsp;void f1(int par) {}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Is compliant or non-compliant?<br />
}</code></div></div>]]></description>
			<content:encoded><![CDATA[Rule A2-10-5 states: Regardless of scope, no identifier with static storage duration should be reused across any source files in the project. Are cases where an identifier is reused as a member non-compliant with this rule? In particular, the case where an operator function is defined as a global and a member function.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct S<br />
{<br />
&nbsp;&nbsp;void operator&lt;&lt;(S&amp;) {}<br />
&nbsp;&nbsp;void f1(int par) {}<br />
};<br />
<br />
namespace N<br />
{<br />
&nbsp;&nbsp;void operator&lt;&lt;(int i, S&amp;) {}&nbsp;&nbsp;// Is compliant or non-compliant?<br />
&nbsp;&nbsp;void f1(int par) {}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Is compliant or non-compliant?<br />
}</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Is Fn4 example in AUTOSAR rule A7-5-2 correct?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1776</link>
			<pubDate>Thu, 02 Jul 2026 10:49:49 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6775">limdor</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1776</guid>
			<description><![CDATA[<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">AUTOSAR rule A7-5-2 has the following example:</span><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>std::int32_t Fn4(std::int32_t number) <br />
{ <br />
  if (number == 1) <br />
  {<br />
    number = number * Fn3(number - 1);  // Non-compliant <br />
  } &nbsp;&nbsp;<br />
  return number; <br />
}</code></div></div> <span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Fn3 is a recursive function and thus non-compliant. Fn4 is making a call to Fn3. However, in this line, the function is not calling itself. Why is this line Non-compliant? Is this an issue with the example?</span>]]></description>
			<content:encoded><![CDATA[<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">AUTOSAR rule A7-5-2 has the following example:</span><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>std::int32_t Fn4(std::int32_t number) <br />
{ <br />
  if (number == 1) <br />
  {<br />
    number = number * Fn3(number - 1);  // Non-compliant <br />
  } &nbsp;&nbsp;<br />
  return number; <br />
}</code></div></div> <span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Fn3 is a recursive function and thus non-compliant. Fn4 is making a call to Fn3. However, in this line, the function is not calling itself. Why is this line Non-compliant? Is this an issue with the example?</span>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[It 8.12 intended to be so strict?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1774</link>
			<pubDate>Thu, 25 Jun 2026 22:05:26 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6753">Loïc</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1774</guid>
			<description><![CDATA[Hello,<br />
<br />
It is clear by looking at the title of rule 8.12 <br />
<blockquote class="mycode_quote"><cite>Quote:</cite>Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique</blockquote>
<br />
That the following code is non-compliant:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>// Non-compliant, yellow has an implixitly defined value that it shares with last<br />
enum colour { red, blue, green, yellow, last = yellow };</code></div></div><br />
This is a relatively common pattern, and the alternatives seem worse.<br />
<br />
It is the intent of this rule to prevent this pattern, or is it just a result of the wording?<br />
By the way, this code is compliant with the C++ version of this rule in MISRA C++:2023.]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
It is clear by looking at the title of rule 8.12 <br />
<blockquote class="mycode_quote"><cite>Quote:</cite>Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique</blockquote>
<br />
That the following code is non-compliant:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>// Non-compliant, yellow has an implixitly defined value that it shares with last<br />
enum colour { red, blue, green, yellow, last = yellow };</code></div></div><br />
This is a relatively common pattern, and the alternatives seem worse.<br />
<br />
It is the intent of this rule to prevent this pattern, or is it just a result of the wording?<br />
By the way, this code is compliant with the C++ version of this rule in MISRA C++:2023.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[10.3 Clarify if narrower in the title refers the the rank of the essential type]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1773</link>
			<pubDate>Thu, 25 Jun 2026 21:03:44 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6753">Loïc</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1773</guid>
			<description><![CDATA[The rule 10.3 says:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>The value of an expression shall not be assigned to an object with a narrower //essential type// </blockquote>
<br />
What does it mean to be narrower? To have a lower rank, or to have a smaller size?<br />
<br />
For instance, on a platform where <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>sizeof(long) == sizeof(long long)</code></div></div><br />
Is the following code compliant with rule 10.3:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>long l = 0;<br />
long long ll = 0;<br />
l = ll; // Compliant or not?</code></div></div><br />
My feeling is that it <span style="font-style: italic;" class="mycode_i">is </span>compliant, because the word <span style="font-style: italic;" class="mycode_i">rank </span>is not used here, while it is explicitly used in other parts of the rule, but I'm not 100% confident.]]></description>
			<content:encoded><![CDATA[The rule 10.3 says:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>The value of an expression shall not be assigned to an object with a narrower //essential type// </blockquote>
<br />
What does it mean to be narrower? To have a lower rank, or to have a smaller size?<br />
<br />
For instance, on a platform where <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>sizeof(long) == sizeof(long long)</code></div></div><br />
Is the following code compliant with rule 10.3:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>long l = 0;<br />
long long ll = 0;<br />
l = ll; // Compliant or not?</code></div></div><br />
My feeling is that it <span style="font-style: italic;" class="mycode_i">is </span>compliant, because the word <span style="font-style: italic;" class="mycode_i">rank </span>is not used here, while it is explicitly used in other parts of the rule, but I'm not 100% confident.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[What is the UTLR of -1?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1772</link>
			<pubDate>Tue, 09 Jun 2026 09:36:31 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6753">Loïc</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1772</guid>
			<description><![CDATA[I'm attempting to determine the essential type of the following expression:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>(unsigned short)1 - (unsigned short)2</code></div></div><br />
This is a operation subject to arithmetic conversion (D.7.9), both operands are essentially unsigned, and the expression is an integer constant expression, so according to item 4.1, the essential type of the result is the UTLR of the result.<br />
<br />
However, the result is a <span style="font-weight: bold;" class="mycode_b">signed</span> integer with the value -1. The following program demonstrates this:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#include &lt;stdio.h&gt;<br />
<br />
<br />
#define TYPE(x) _Generic((x), &#92;<br />
    int: printf("int&#92;n"), &#92;<br />
    unsigned int: printf("unsigned int&#92;n"), &#92;<br />
    default: printf("other&#92;n") &#92;<br />
)<br />
<br />
int main() {<br />
    TYPE(1u - 2u);  <br />
    TYPE(1 - 2);  <br />
    TYPE((unsigned short)1 - (unsigned short)2);<br />
}</code></div></div><br />
<br />
<br />
So we have to compute the UTLR of a negative value, which is not defined.<br />
<br />
Is there an error in my reasoning, or is this a limitation in the essential type system?]]></description>
			<content:encoded><![CDATA[I'm attempting to determine the essential type of the following expression:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>(unsigned short)1 - (unsigned short)2</code></div></div><br />
This is a operation subject to arithmetic conversion (D.7.9), both operands are essentially unsigned, and the expression is an integer constant expression, so according to item 4.1, the essential type of the result is the UTLR of the result.<br />
<br />
However, the result is a <span style="font-weight: bold;" class="mycode_b">signed</span> integer with the value -1. The following program demonstrates this:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#include &lt;stdio.h&gt;<br />
<br />
<br />
#define TYPE(x) _Generic((x), &#92;<br />
    int: printf("int&#92;n"), &#92;<br />
    unsigned int: printf("unsigned int&#92;n"), &#92;<br />
    default: printf("other&#92;n") &#92;<br />
)<br />
<br />
int main() {<br />
    TYPE(1u - 2u);  <br />
    TYPE(1 - 2);  <br />
    TYPE((unsigned short)1 - (unsigned short)2);<br />
}</code></div></div><br />
<br />
<br />
So we have to compute the UTLR of a negative value, which is not defined.<br />
<br />
Is there an error in my reasoning, or is this a limitation in the essential type system?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[13.2 Was TC2 correctly applied to the rule in MISRA C:2023?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1771</link>
			<pubDate>Wed, 03 Jun 2026 15:27:35 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6753">Loïc</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1771</guid>
			<description><![CDATA[Hello,<br />
<br />
TC2 says:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>TC 2.23 : In the “Amplification” section, number the existing two notes as 1 and 3 respectively. <br />
TC 2.24 : In the “Amplification” section, insert a new note 2 between the existing two notes: 2. All parts of the expression are considered when determining whether an object is read or modified, irrespective of any known values </blockquote>
<br />
But when looking at MISRA C:2023, we only see 2 notes, and the text that was supposed to be inserted as node 2 appears in second position in the bullet list above the notes.<br />
<br />
Which is right? The TC2, or the 2023 version?<br />
<br />
Thank you,]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
TC2 says:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>TC 2.23 : In the “Amplification” section, number the existing two notes as 1 and 3 respectively. <br />
TC 2.24 : In the “Amplification” section, insert a new note 2 between the existing two notes: 2. All parts of the expression are considered when determining whether an object is read or modified, irrespective of any known values </blockquote>
<br />
But when looking at MISRA C:2023, we only see 2 notes, and the text that was supposed to be inserted as node 2 appears in second position in the bullet list above the notes.<br />
<br />
Which is right? The TC2, or the 2023 version?<br />
<br />
Thank you,]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6.5.2: Missing exception for static class members?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1770</link>
			<pubDate>Tue, 02 Jun 2026 07:14:08 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6672">pwolf</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1770</guid>
			<description><![CDATA[The wording of rule 6.5.2 seems to imply that any entity with internal linkage may not be declared static, even though the static keyword “also has other uses”.<br />
With that interpretation, the rule would completely prohibit the use of static class members with internal linkage.<br />
<br />
For example, given this code snippet:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>static void F1() {} // 1<br />
<br />
namespace {<br />
<br />
static void F2() {} // 2<br />
<br />
class Klass {<br />
  public:<br />
    static void F3() {} // 3<br />
};<br />
<br />
} // namespace</code></div></div><br />
<br />
In cases 1 and 2, the static keyword is “inappropriate”. F1 should be declared inside the anonymous namespace instead and for F2 the static keyword could be simply dropped.<br />
F3 has internal linkage but the static is not used for linkage but to make the function a class function. Still, the amplification of rule 6.5.2 says that internal linkage of an entity is only appropriate if it’s not declared static, which F3 clearly is.<br />
<br />
Is that intentional? Should the wording be improved to make it clear that only static declarations which could affect linkage are considered?<br />
Or (to simplify static analysis) could an exception be added for static class members?]]></description>
			<content:encoded><![CDATA[The wording of rule 6.5.2 seems to imply that any entity with internal linkage may not be declared static, even though the static keyword “also has other uses”.<br />
With that interpretation, the rule would completely prohibit the use of static class members with internal linkage.<br />
<br />
For example, given this code snippet:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>static void F1() {} // 1<br />
<br />
namespace {<br />
<br />
static void F2() {} // 2<br />
<br />
class Klass {<br />
  public:<br />
    static void F3() {} // 3<br />
};<br />
<br />
} // namespace</code></div></div><br />
<br />
In cases 1 and 2, the static keyword is “inappropriate”. F1 should be declared inside the anonymous namespace instead and for F2 the static keyword could be simply dropped.<br />
F3 has internal linkage but the static is not used for linkage but to make the function a class function. Still, the amplification of rule 6.5.2 says that internal linkage of an entity is only appropriate if it’s not declared static, which F3 clearly is.<br />
<br />
Is that intentional? Should the wording be improved to make it clear that only static declarations which could affect linkage are considered?<br />
Or (to simplify static analysis) could an exception be added for static class members?]]></content:encoded>
		</item>
	</channel>
</rss>