<?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.17 Functions]]></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:55 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Rule 17.3 when function has definition]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1651</link>
			<pubDate>Thu, 15 Jun 2023 14:32:32 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6164">dunno</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1651</guid>
			<description><![CDATA[I wonder if the code below violates rule 17.3:<br />
<br />
void dostuff(int x) {<br />
    // do some stuff..<br />
}<br />
<br />
void func(void) {<br />
    dostuff(12);   // &lt;- is 17.3 violated here?<br />
}<br />
<br />
Please note that the functions dostuff and func violates rule 8.4 and don't have prototypes.<br />
<br />
Question: is 17.3 violated when calling a function that violates rule 8.4?<br />
<br />
The rationale for 17.3 also does not apply to my example code as far as I understand:<br />
<br />
<span style="color: #232629;" class="mycode_color"><span style="font-size: small;" class="mycode_size"><span style="font-family: monospace;" class="mycode_font">    If a function is declared implicitly, a C90 compiler will assume</span></span></span><br />
<span style="color: #232629;" class="mycode_color"><span style="font-size: small;" class="mycode_size"><span style="font-family: monospace;" class="mycode_font">    that the function has a return type of int. Since an implicit </span></span></span><br />
<span style="color: #232629;" class="mycode_color"><span style="font-size: small;" class="mycode_size"><span style="font-family: monospace;" class="mycode_font">    function declaration does not provide a prototype, a compiler will</span></span></span><br />
<span style="color: #232629;" class="mycode_color"><span style="font-size: small;" class="mycode_size"><span style="font-family: monospace;" class="mycode_font">    have no information about the number of function parameters and</span></span></span><br />
<span style="color: #232629;" class="mycode_color"><span style="font-size: small;" class="mycode_size"><span style="font-family: monospace;" class="mycode_font">    their types. </span></span></span>]]></description>
			<content:encoded><![CDATA[I wonder if the code below violates rule 17.3:<br />
<br />
void dostuff(int x) {<br />
    // do some stuff..<br />
}<br />
<br />
void func(void) {<br />
    dostuff(12);   // &lt;- is 17.3 violated here?<br />
}<br />
<br />
Please note that the functions dostuff and func violates rule 8.4 and don't have prototypes.<br />
<br />
Question: is 17.3 violated when calling a function that violates rule 8.4?<br />
<br />
The rationale for 17.3 also does not apply to my example code as far as I understand:<br />
<br />
<span style="color: #232629;" class="mycode_color"><span style="font-size: small;" class="mycode_size"><span style="font-family: monospace;" class="mycode_font">    If a function is declared implicitly, a C90 compiler will assume</span></span></span><br />
<span style="color: #232629;" class="mycode_color"><span style="font-size: small;" class="mycode_size"><span style="font-family: monospace;" class="mycode_font">    that the function has a return type of int. Since an implicit </span></span></span><br />
<span style="color: #232629;" class="mycode_color"><span style="font-size: small;" class="mycode_size"><span style="font-family: monospace;" class="mycode_font">    function declaration does not provide a prototype, a compiler will</span></span></span><br />
<span style="color: #232629;" class="mycode_color"><span style="font-size: small;" class="mycode_size"><span style="font-family: monospace;" class="mycode_font">    have no information about the number of function parameters and</span></span></span><br />
<span style="color: #232629;" class="mycode_color"><span style="font-size: small;" class="mycode_size"><span style="font-family: monospace;" class="mycode_font">    their types. </span></span></span>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 17.4 and main]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1582</link>
			<pubDate>Fri, 01 Oct 2021 09:59:21 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5715">hummelvario</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1582</guid>
			<description><![CDATA[Hello,<br />
we are facing a conflict between armclang compiler warning and mandatory MISRA Rule.<br />
The armclang compiler V6.16 seems to require "int main", but if we adhere to Rule 17.4 adding "return 0" at the end of main it is leading to a compiler warning.<br />
(warning: 'return' will never be executed [-Wunreachable-code-return])<br />
<br />
Who is having the higher priority here to comply with MISRA?<br />
Is it required to deactivate / ignore the compiler warning at this point?<br />
<br />
According to the C Standard, 5.1.2.2.3, paragraph 1 [ISO/IEC 9899:2011], "Reaching the } that terminates the main function returns a value of 0." <br />
Is there another possibility to comply with the MISRA Rule 17.4?]]></description>
			<content:encoded><![CDATA[Hello,<br />
we are facing a conflict between armclang compiler warning and mandatory MISRA Rule.<br />
The armclang compiler V6.16 seems to require "int main", but if we adhere to Rule 17.4 adding "return 0" at the end of main it is leading to a compiler warning.<br />
(warning: 'return' will never be executed [-Wunreachable-code-return])<br />
<br />
Who is having the higher priority here to comply with MISRA?<br />
Is it required to deactivate / ignore the compiler warning at this point?<br />
<br />
According to the C Standard, 5.1.2.2.3, paragraph 1 [ISO/IEC 9899:2011], "Reaching the } that terminates the main function returns a value of 0." <br />
Is there another possibility to comply with the MISRA Rule 17.4?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 17.5 and arrays of size 1]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1423</link>
			<pubDate>Tue, 15 May 2018 22:09:57 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=1246">gdavis</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1423</guid>
			<description><![CDATA[Hello,<br />
<br />
Please consider the following case:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#include <br />
extern void f(int32_t x[1]);<br />
int32_t glob;<br />
extern void test(void);<br />
void test(void)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;f(&amp;glob); /* Allowed under MISRA C 2012 R17.5? */<br />
}</code></div></div><br />
Could you confirm if the intent that this should be a violation of the rule since we are passing a non-array as an argument where an array is expected?  I ask only because there is related wording in the C90/99 standard under additive operators that states:<br />
<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>For the purposes of these operators, a pointer to a nonarray object behaves the same as a<br />
pointer to the first element of an array of length one with the type of the object as its element<br />
type.</blockquote>
<br />
Thank you for your help.<br />
<br />
Best Regards,<br />
<br />
-Greg]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
Please consider the following case:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#include <br />
extern void f(int32_t x[1]);<br />
int32_t glob;<br />
extern void test(void);<br />
void test(void)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;f(&amp;glob); /* Allowed under MISRA C 2012 R17.5? */<br />
}</code></div></div><br />
Could you confirm if the intent that this should be a violation of the rule since we are passing a non-array as an argument where an array is expected?  I ask only because there is related wording in the C90/99 standard under additive operators that states:<br />
<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>For the purposes of these operators, a pointer to a nonarray object behaves the same as a<br />
pointer to the first element of an array of length one with the type of the object as its element<br />
type.</blockquote>
<br />
Thank you for your help.<br />
<br />
Best Regards,<br />
<br />
-Greg]]></content:encoded>
		</item>
	</channel>
</rss>