<?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.19 Overlapping storage]]></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:42 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Rule 19.1 and assigment between members of a struct]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1216</link>
			<pubDate>Fri, 20 Nov 2015 10:34:11 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=980">GerlindeKettl</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1216</guid>
			<description><![CDATA[Does this code violate rule 19.1?<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct s_tag {&nbsp;&nbsp;<br />
uint8 ReadPos;<br />
uint8 WritePos; }; <br />
typedef struct s_tag s;<br />
<br />
union u_tag { <br />
s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Elements;<br />
uint32 Value; }; <br />
typedef union u_tag u; <br />
<br />
u NewState;<br />
NewState.Elements.ReadPos&nbsp;&nbsp;= NewState.Elements.WritePos;</code></div></div>My static code checker thinks it is a violation, but from my point of view I'm just assigning one member of a struct to a different member of the struct and they don't overlap in memory. That this struct is a member of a union should not matter as there is no assignment across the members of the union.]]></description>
			<content:encoded><![CDATA[Does this code violate rule 19.1?<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct s_tag {&nbsp;&nbsp;<br />
uint8 ReadPos;<br />
uint8 WritePos; }; <br />
typedef struct s_tag s;<br />
<br />
union u_tag { <br />
s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Elements;<br />
uint32 Value; }; <br />
typedef union u_tag u; <br />
<br />
u NewState;<br />
NewState.Elements.ReadPos&nbsp;&nbsp;= NewState.Elements.WritePos;</code></div></div>My static code checker thinks it is a violation, but from my point of view I'm just assigning one member of a struct to a different member of the struct and they don't overlap in memory. That this struct is a member of a union should not matter as there is no assignment across the members of the union.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 19.1 and assignment of one element of array]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1208</link>
			<pubDate>Thu, 29 Oct 2015 05:41:08 +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=1208</guid>
			<description><![CDATA[Would the following examples be compliant with rule #19.1?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int16_t a[20];<br />
void g(void) <br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;int16_t *p = &amp;a[0];<br />
&nbsp;&nbsp;&nbsp;&nbsp;int16_t *q = &amp;a[0];<br />
&nbsp;&nbsp;&nbsp;&nbsp;*p = *q;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Compliant - exception 1 */<br />
}<br />
void f(void) <br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;int16_t *p = &amp;a[0];<br />
&nbsp;&nbsp;&nbsp;&nbsp;int16_t *q = &amp;a[1];<br />
&nbsp;&nbsp;&nbsp;&nbsp;*p = *q;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // here, is it Compliant ?<br />
}</code></div></div>]]></description>
			<content:encoded><![CDATA[Would the following examples be compliant with rule #19.1?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int16_t a[20];<br />
void g(void) <br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;int16_t *p = &amp;a[0];<br />
&nbsp;&nbsp;&nbsp;&nbsp;int16_t *q = &amp;a[0];<br />
&nbsp;&nbsp;&nbsp;&nbsp;*p = *q;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Compliant - exception 1 */<br />
}<br />
void f(void) <br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;int16_t *p = &amp;a[0];<br />
&nbsp;&nbsp;&nbsp;&nbsp;int16_t *q = &amp;a[1];<br />
&nbsp;&nbsp;&nbsp;&nbsp;*p = *q;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // here, is it Compliant ?<br />
}</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 19.1 Example]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1022</link>
			<pubDate>Wed, 22 Jan 2014 07:33:12 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=3078">minoru.kanome</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1022</guid>
			<description><![CDATA[rule 19.1 example :<br />
<br />
  a = b;  /* Compliant - exception 1 */<br />
<br />
<span style="font-weight: bold;" class="mycode_b">a</span> and <span style="font-weight: bold;" class="mycode_b">b</span> are not overlapping object.<br />
Therefore, this code is improper as the example.<br />
Is it right?]]></description>
			<content:encoded><![CDATA[rule 19.1 example :<br />
<br />
  a = b;  /* Compliant - exception 1 */<br />
<br />
<span style="font-weight: bold;" class="mycode_b">a</span> and <span style="font-weight: bold;" class="mycode_b">b</span> are not overlapping object.<br />
Therefore, this code is improper as the example.<br />
Is it right?]]></content:encoded>
		</item>
	</channel>
</rss>