<?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 - 4.10 Declarations]]></title>
		<link>https://forum.misra.org.uk/</link>
		<description><![CDATA[MISRA Discussion Forums - https://forum.misra.org.uk]]></description>
		<pubDate>Thu, 12 Nov 2026 16:20:30 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Rule 10.1.1]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1745</link>
			<pubDate>Mon, 04 Aug 2025 07:59:07 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6654">Merge</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1745</guid>
			<description><![CDATA[<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Hi,</span><br />
<br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">We are having a discussion with one of our tool vendors about how to interpret MISRA C++ 2023 rule 10.1.1, more concretely, the impact of the implicit 'this' parameter. I won't say which party supports which interpretation for the sake of neutrality.</span><br />
<br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Example code:<br />
<a href="https://godbolt.org/z/hxz4bzvan" target="_blank" rel="noopener" class="mycode_url">https://godbolt.org/z/hxz4bzvan</a></span><br />
<br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Interpretation A)<br />
Fn() has an implicit, non-const 'this' parameter, so the rule is violated (Fn() should have been declared const).</span><br />
<br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Interpretation B)<br />
Fn() does not have any parameters, so the rule is not violated.</span><br />
<br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">We would appreciate an unbiased opinion to settle this discussion.</span><br />
<br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Best regards,</span><br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Daniel "Merge" Merget</span>]]></description>
			<content:encoded><![CDATA[<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Hi,</span><br />
<br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">We are having a discussion with one of our tool vendors about how to interpret MISRA C++ 2023 rule 10.1.1, more concretely, the impact of the implicit 'this' parameter. I won't say which party supports which interpretation for the sake of neutrality.</span><br />
<br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Example code:<br />
<a href="https://godbolt.org/z/hxz4bzvan" target="_blank" rel="noopener" class="mycode_url">https://godbolt.org/z/hxz4bzvan</a></span><br />
<br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Interpretation A)<br />
Fn() has an implicit, non-const 'this' parameter, so the rule is violated (Fn() should have been declared const).</span><br />
<br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Interpretation B)<br />
Fn() does not have any parameters, so the rule is not violated.</span><br />
<br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">We would appreciate an unbiased opinion to settle this discussion.</span><br />
<br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Best regards,</span><br />
<span style="font-family: 'Open Sans', sans-serif;" class="mycode_font">Daniel "Merge" Merget</span>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 10.1.2: Justification for considering volatile member functions as inappropriate]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1696</link>
			<pubDate>Wed, 14 Aug 2024 15:34:24 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6450">Nicolas Huch</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1696</guid>
			<description><![CDATA[I seek justification for why declaring a member function as volatile is considered an inappropriate use of the volatile qualifier.<br />
<br />
The other inappropriate use cases (local variables, function parameters, function return types, and structured bindings) are justifiable to me since they are not bound to specific memory addresses, which may be out of scope for the C++ virtual machine to reason about. Instead, they are typically automatic variables located on the stack or only exist in registers, which conflicts with the concept of volatile.<br />
<br />
However, a class object might be located at a specific memory address where it could abstract a memory-mapped register. Such an object must be declared as volatile. To call non-static member functions on such an object, those functions must also be declared as volatile.<br />
<br />
The justification for all of the inappropriate use cases mentions that the behavior is not well-defined or well-understood, but the standard clearly states the behavior in the case of non-static member functions:<br />
<br />
Declaring a non-static member function as volatile will influence the type of the <span style="font-weight: bold;" class="mycode_b">this </span>pointer as well as the member function type (12.2.2 [4]). Section 12.2.2.1 [1] further clarifies that the type of the object referred to by the <span style="font-weight: bold;" class="mycode_b">this </span>pointer is qualified with the same cv-qualifiers as those used for the non-static member function.<br />
<br />
Additionally, MISRA Rule 10.1.2 explicitly states in a note that "a pointer or reference to a volatile entity is permitted", which contradicts the notion that declaring a volatile member function is an inappropriate use of the volatile qualifier.<br />
<br />
Are there further aspects I am missing or wrong assumptions in my reasoning?<br />
<br />
Kind regards<br />
Nicolas]]></description>
			<content:encoded><![CDATA[I seek justification for why declaring a member function as volatile is considered an inappropriate use of the volatile qualifier.<br />
<br />
The other inappropriate use cases (local variables, function parameters, function return types, and structured bindings) are justifiable to me since they are not bound to specific memory addresses, which may be out of scope for the C++ virtual machine to reason about. Instead, they are typically automatic variables located on the stack or only exist in registers, which conflicts with the concept of volatile.<br />
<br />
However, a class object might be located at a specific memory address where it could abstract a memory-mapped register. Such an object must be declared as volatile. To call non-static member functions on such an object, those functions must also be declared as volatile.<br />
<br />
The justification for all of the inappropriate use cases mentions that the behavior is not well-defined or well-understood, but the standard clearly states the behavior in the case of non-static member functions:<br />
<br />
Declaring a non-static member function as volatile will influence the type of the <span style="font-weight: bold;" class="mycode_b">this </span>pointer as well as the member function type (12.2.2 [4]). Section 12.2.2.1 [1] further clarifies that the type of the object referred to by the <span style="font-weight: bold;" class="mycode_b">this </span>pointer is qualified with the same cv-qualifiers as those used for the non-static member function.<br />
<br />
Additionally, MISRA Rule 10.1.2 explicitly states in a note that "a pointer or reference to a volatile entity is permitted", which contradicts the notion that declaring a volatile member function is an inappropriate use of the volatile qualifier.<br />
<br />
Are there further aspects I am missing or wrong assumptions in my reasoning?<br />
<br />
Kind regards<br />
Nicolas]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[10.2.3 Amplification]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1678</link>
			<pubDate>Tue, 26 Mar 2024 15:08:25 +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=1678</guid>
			<description><![CDATA[Hi,<br />
<br />
I find the amplification of rule 10.2.3 confusing.<br />
<br />
In general I wonder what the difference to a simple "no implicit conversion from unscoped enumeration type without underlying type to numeric type" (plus the exception for static_cast in bullet point 3) is?<br />
<br />
In particular, as example, for the following code<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>enum E {E1, E2};<br />
int f(int);<br />
E operator+(E, E);<br />
int main() {<br />
  E e = E1;<br />
  f(e); // Compliant? (1)<br />
  e = e + e; // Non-compliant (2)<br />
}</code></div></div>I wonder whether (1) should be compliant or not. At least it is not listed in the amplification, but seems like a problematic case anyway.<br />
In turn, should (2) be non-compliant as operands to "arithmetic operator" are explicitly listed in the amplification, while I think this case is absolutely fine.<br />
<br />
It would be great to get a clarification on what the rule intends.]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
I find the amplification of rule 10.2.3 confusing.<br />
<br />
In general I wonder what the difference to a simple "no implicit conversion from unscoped enumeration type without underlying type to numeric type" (plus the exception for static_cast in bullet point 3) is?<br />
<br />
In particular, as example, for the following code<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>enum E {E1, E2};<br />
int f(int);<br />
E operator+(E, E);<br />
int main() {<br />
  E e = E1;<br />
  f(e); // Compliant? (1)<br />
  e = e + e; // Non-compliant (2)<br />
}</code></div></div>I wonder whether (1) should be compliant or not. At least it is not listed in the amplification, but seems like a problematic case anyway.<br />
In turn, should (2) be non-compliant as operands to "arithmetic operator" are explicitly listed in the amplification, while I think this case is absolutely fine.<br />
<br />
It would be great to get a clarification on what the rule intends.]]></content:encoded>
		</item>
	</channel>
</rss>