<?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.18 Pointers and arrays]]></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:49 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Rule 18.8 and clarification of "use" of VLA types]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1384</link>
			<pubDate>Fri, 27 Oct 2017 16:23:22 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=318">rgamble</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1384</guid>
			<description><![CDATA[What exactly is meant by the "use" of "variable-length array types"?  The examples suggest that the mere declaration of an object of variable length array type violates this rule which makes sense if the declaration is thought of as "using" the VLA type.<br />
<br />
The example below declares a <span style="font-style: italic;" class="mycode_i">pointer</span> to a VLA type and then dereferences the pointer:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>typedef unsigned uint32_t;<br />
typedef int int32_t;<br />
<br />
void foo(uint32_t sz, int32_t (*ary)[sz], int32_t val) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;(*ary)[0] = val;<br />
}</code></div></div><br />
Is the declaration of the pointer parameter <span style="font-weight: bold;" class="mycode_b">ary</span> a violation of this rule?  Is the statement that dereferences <span style="font-weight: bold;" class="mycode_b">ary</span> a violation of this rule?]]></description>
			<content:encoded><![CDATA[What exactly is meant by the "use" of "variable-length array types"?  The examples suggest that the mere declaration of an object of variable length array type violates this rule which makes sense if the declaration is thought of as "using" the VLA type.<br />
<br />
The example below declares a <span style="font-style: italic;" class="mycode_i">pointer</span> to a VLA type and then dereferences the pointer:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>typedef unsigned uint32_t;<br />
typedef int int32_t;<br />
<br />
void foo(uint32_t sz, int32_t (*ary)[sz], int32_t val) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;(*ary)[0] = val;<br />
}</code></div></div><br />
Is the declaration of the pointer parameter <span style="font-weight: bold;" class="mycode_b">ary</span> a violation of this rule?  Is the statement that dereferences <span style="font-weight: bold;" class="mycode_b">ary</span> a violation of this rule?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 18.1 and Rule 11.3 compatibility]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1243</link>
			<pubDate>Fri, 06 May 2016 15:29:42 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=4381">m.bruna</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1243</guid>
			<description><![CDATA[Hi, <br />
<br />
i am not sure about compliance of following example.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>uint32_t varialble = 0;<br />
uint8_t * ptr = (uint8_t *)variable;<br />
<br />
(*ptr) = 0;<br />
ptr++;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//line in question<br />
(*ptr) = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//line in question</code></div></div><br />
While exception to the rule 11.3 clearly says, that converting the pointer to object to pointer to char is ok and can be used for accessing individual bytes, Rule 18.1 says that object that is not an array shall be treated as an array of single element and does not allow dereferencing a pointer beyond the end of it. <br />
<br />
Can an object that is not an array be treated as an array of 8-bit variables with length of its byte size for this purpose? or can i only access the first byte of the object this way? <br />
<br />
thanks,<br />
<br />
Michal]]></description>
			<content:encoded><![CDATA[Hi, <br />
<br />
i am not sure about compliance of following example.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>uint32_t varialble = 0;<br />
uint8_t * ptr = (uint8_t *)variable;<br />
<br />
(*ptr) = 0;<br />
ptr++;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//line in question<br />
(*ptr) = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//line in question</code></div></div><br />
While exception to the rule 11.3 clearly says, that converting the pointer to object to pointer to char is ok and can be used for accessing individual bytes, Rule 18.1 says that object that is not an array shall be treated as an array of single element and does not allow dereferencing a pointer beyond the end of it. <br />
<br />
Can an object that is not an array be treated as an array of 8-bit variables with length of its byte size for this purpose? or can i only access the first byte of the object this way? <br />
<br />
thanks,<br />
<br />
Michal]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 18.4, 10.1, and the "type" of pointer to object]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1204</link>
			<pubDate>Thu, 01 Oct 2015 18:48:02 +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=1204</guid>
			<description><![CDATA[Within our development group, there has been some discussion as to whether or not the construction<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>void test(uint8_t * up)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;bool invalid = !up;<br />
&nbsp;&nbsp;&nbsp;&nbsp;...<br />
}</code></div></div>is valid with regard to the usage of '!' against a pointer.  According to the 18.X rules, '!' is not disallowed for use on pointers, but the explanation of Rule 10.1 with regards to the appropriate essential type for use with '!' would indicate that, as a non-Boolean, its use on pointers should be disallowed.<br />
<br />
Do pointers have an "essential type" under the essential type model and what is the correct interpretation in this case?]]></description>
			<content:encoded><![CDATA[Within our development group, there has been some discussion as to whether or not the construction<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>void test(uint8_t * up)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;bool invalid = !up;<br />
&nbsp;&nbsp;&nbsp;&nbsp;...<br />
}</code></div></div>is valid with regard to the usage of '!' against a pointer.  According to the 18.X rules, '!' is not disallowed for use on pointers, but the explanation of Rule 10.1 with regards to the appropriate essential type for use with '!' would indicate that, as a non-Boolean, its use on pointers should be disallowed.<br />
<br />
Do pointers have an "essential type" under the essential type model and what is the correct interpretation in this case?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 18.4 using -- operator for pointers]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1078</link>
			<pubDate>Thu, 17 Jul 2014 06:28:19 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=3328">simondl</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1078</guid>
			<description><![CDATA[Dear<br />
<br />
Rule 18.4 mentions +, -, += and -= operators and also ++ operator (both post and pre fix?). -- operator is not mentioned. How to deal with it?<br />
<br />
Regards]]></description>
			<content:encoded><![CDATA[Dear<br />
<br />
Rule 18.4 mentions +, -, += and -= operators and also ++ operator (both post and pre fix?). -- operator is not mentioned. How to deal with it?<br />
<br />
Regards]]></content:encoded>
		</item>
	</channel>
</rss>