<?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.11 Declarators]]></title>
		<link>https://forum.misra.org.uk/</link>
		<description><![CDATA[MISRA Discussion Forums - https://forum.misra.org.uk]]></description>
		<pubDate>Thu, 05 Nov 2026 19:06:33 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Rule 11.6.1 - Variables initialized via output-parameter?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1748</link>
			<pubDate>Tue, 02 Sep 2025 11:26:09 +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=1748</guid>
			<description><![CDATA[Hi,<br />
<br />
Consider the following example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>// external_c_api.h<br />
enum error_t<br />
{<br />
&nbsp;&nbsp;// ...<br />
};<br />
<br />
enum foo_t<br />
{<br />
&nbsp;&nbsp;foo_A = 1,<br />
&nbsp;&nbsp;foo_B = 2<br />
};<br />
<br />
error_t externalCApi(foo_t*);<br />
<br />
// main.cpp<br />
void f()<br />
{<br />
  foo_t x;<br />
  error_t error = externalCApi(&amp;x);<br />
}</code></div></div><br />
How would one apply 11.6.1 in this case? It's not possible to avoid the two-step initialization process. There may not even be a "sensible default" to give to `x` before giving it the "real" value (and MISRA explicitly discourages this pattern). In particular, doing "foo_t x{};" leads to zero initialization, but there is no enumerator with the value 0.<br />
<br />
Thanks!]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
Consider the following example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>// external_c_api.h<br />
enum error_t<br />
{<br />
&nbsp;&nbsp;// ...<br />
};<br />
<br />
enum foo_t<br />
{<br />
&nbsp;&nbsp;foo_A = 1,<br />
&nbsp;&nbsp;foo_B = 2<br />
};<br />
<br />
error_t externalCApi(foo_t*);<br />
<br />
// main.cpp<br />
void f()<br />
{<br />
  foo_t x;<br />
  error_t error = externalCApi(&amp;x);<br />
}</code></div></div><br />
How would one apply 11.6.1 in this case? It's not possible to avoid the two-step initialization process. There may not even be a "sensible default" to give to `x` before giving it the "real" value (and MISRA explicitly discourages this pattern). In particular, doing "foo_t x{};" leads to zero initialization, but there is no enumerator with the value 0.<br />
<br />
Thanks!]]></content:encoded>
		</item>
	</channel>
</rss>