<?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 - 6.18 Language support library (C++)]]></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:59 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[About Rule 18-4-1 "Dynamic heap memory allocation shall not be used."]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1482</link>
			<pubDate>Mon, 25 Mar 2019 18:38:26 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=4892">Sebastien.Ashby@nxp</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1482</guid>
			<description><![CDATA[Hi,<br />
<br />
I have a question about Rule 18-4-1 "Dynamic heap memory allocation shall not be used.".<br />
<br />
C++ already has a form of memory allocation for its automatic variables.<br />
That is they are allocated on the stack.<br />
I take for granted that this form of memory allocation is allowed by MISRA.<br />
<br />
Would managing and allocating the heap space in a stack fashion address most concerns associated with rule 18-4-1?<br />
<br />
For example, the call stack is also subject to out-of-storage runtime failure, i.e. stack overflow.<br />
The call stack being used to store a host of values associated with function calls and its depth may be based on runtime values.<br />
The only way to secure against this being to find the worst case your system allows and set the stack size accordingly.<br />
<br />
If the heap space allocator was not subject to:<br />
<ul class="mycode_list"><li>Memory leaks<br />
Non-deterministic behavior<ul class="mycode_list"><li>Fragmentation<br />
Order of allocation/deallocation<br />
</li>
</ul>
</li>
</ul>
<br />
And the memory exhaustion case was handled in the same fashion as the call stack.<br />
Meaning testing your system to find the worst case and ensuring that at least that amount is available.<br />
<br />
Would this type of dynamic heap memory allocation be compliant with the intent of rule 18-4-1?<br />
<br />
<br />
Best regards.<br />
<br />
Sebastien Ashby]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
I have a question about Rule 18-4-1 "Dynamic heap memory allocation shall not be used.".<br />
<br />
C++ already has a form of memory allocation for its automatic variables.<br />
That is they are allocated on the stack.<br />
I take for granted that this form of memory allocation is allowed by MISRA.<br />
<br />
Would managing and allocating the heap space in a stack fashion address most concerns associated with rule 18-4-1?<br />
<br />
For example, the call stack is also subject to out-of-storage runtime failure, i.e. stack overflow.<br />
The call stack being used to store a host of values associated with function calls and its depth may be based on runtime values.<br />
The only way to secure against this being to find the worst case your system allows and set the stack size accordingly.<br />
<br />
If the heap space allocator was not subject to:<br />
<ul class="mycode_list"><li>Memory leaks<br />
Non-deterministic behavior<ul class="mycode_list"><li>Fragmentation<br />
Order of allocation/deallocation<br />
</li>
</ul>
</li>
</ul>
<br />
And the memory exhaustion case was handled in the same fashion as the call stack.<br />
Meaning testing your system to find the worst case and ensuring that at least that amount is available.<br />
<br />
Would this type of dynamic heap memory allocation be compliant with the intent of rule 18-4-1?<br />
<br />
<br />
Best regards.<br />
<br />
Sebastien Ashby]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 18-0-5 scope]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1338</link>
			<pubDate>Wed, 19 Apr 2017 10:47:18 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=4389">dg1980</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1338</guid>
			<description><![CDATA[Does this rule apply to memcpy as well?<br />
The heading of the rule uses the generic term <span style="font-style: italic;" class="mycode_i">functions</span> while the body of the rule explicitly lists all <span style="font-style: italic;" class="mycode_i">string functions</span> -&gt; confusing!<br />
So, since memcpy is declared in  the heading would fit here, while the body does not.<br />
Nevertheless, since memcpy_s etc. is not available in C99/C++03 i think a deviation with reason "code quality/portability" would be justified.<br />
Do you agree?]]></description>
			<content:encoded><![CDATA[Does this rule apply to memcpy as well?<br />
The heading of the rule uses the generic term <span style="font-style: italic;" class="mycode_i">functions</span> while the body of the rule explicitly lists all <span style="font-style: italic;" class="mycode_i">string functions</span> -&gt; confusing!<br />
So, since memcpy is declared in  the heading would fit here, while the body does not.<br />
Nevertheless, since memcpy_s etc. is not available in C99/C++03 i think a deviation with reason "code quality/portability" would be justified.<br />
Do you agree?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Synchronization with MISRA C 2012]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1274</link>
			<pubDate>Wed, 21 Sep 2016 12:27:38 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=4389">dg1980</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1274</guid>
			<description><![CDATA[Dear MISRA team,<br />
<br />
i recently stumbled upon Rule 21.9 of MISRA C 2012 which prohibits use of bsearch/qsort.<br />
Currently, there is no equivalent in MISRA C++ 2008, so it would be legal to use bsearch/qsort in C++ (if you use cstdlib that is).<br />
Maybe this is another synchronization topic for the next version of the standard (along with the preprocessor usage, see <a href="https://misra.org.uk/forum/viewtopic.php?f=200&amp;t=1549#p3031" target="_blank" rel="noopener" class="mycode_url">https://misra.org.uk/forum/viewtopic.php...1549#p3031</a>).<br />
Thanks.]]></description>
			<content:encoded><![CDATA[Dear MISRA team,<br />
<br />
i recently stumbled upon Rule 21.9 of MISRA C 2012 which prohibits use of bsearch/qsort.<br />
Currently, there is no equivalent in MISRA C++ 2008, so it would be legal to use bsearch/qsort in C++ (if you use cstdlib that is).<br />
Maybe this is another synchronization topic for the next version of the standard (along with the preprocessor usage, see <a href="https://misra.org.uk/forum/viewtopic.php?f=200&amp;t=1549#p3031" target="_blank" rel="noopener" class="mycode_url">https://misra.org.uk/forum/viewtopic.php...1549#p3031</a>).<br />
Thanks.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 18-4-1 (ban of dynamic heap memory allocation)]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=586</link>
			<pubDate>Mon, 29 Sep 2008 09:28:54 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=704">shanz</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=586</guid>
			<description><![CDATA[One of the most commonly quoted advantages of object orientation is polymorphism.<br />
C++ often relies on dynamically allocated pointers to achieve (run-time) polymorphism.<br />
<br />
How can polymorphism be achieved without resorting to dynamic memory allocation?<br />
I suspect that preallocating pointers on the stack is the answer but can someone please write some example code?<br />
<br />
Thanks.]]></description>
			<content:encoded><![CDATA[One of the most commonly quoted advantages of object orientation is polymorphism.<br />
C++ often relies on dynamically allocated pointers to achieve (run-time) polymorphism.<br />
<br />
How can polymorphism be achieved without resorting to dynamic memory allocation?<br />
I suspect that preallocating pointers on the stack is the answer but can someone please write some example code?<br />
<br />
Thanks.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[What is the intention of the rule 18-0-1?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=580</link>
			<pubDate>Thu, 11 Sep 2008 13:03:41 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=688">nakagawat</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=580</guid>
			<description><![CDATA[The Rule 18-0-1 of the MISRA-C++:2008 prohibits developers from using <br />
C libraries entirely. At the same time, the 'Rationale' section of this <br />
rule admits the use of the C++ libraries which correspond to C libraries.<br />
<br />
Many of the C++ libraries corresponding to C libraries are defined<br />
as the C libraries surrounded by the std namespace. For the reason, <br />
we think even if the C++ libraries corresponding to C libraries<br />
are used, it is impossible to avoid such vulnerability C libraries<br />
have as undefined behavior and unspecified behavior.<br />
<br />
Why does the Rule 18-0-1 admit the use of the C++ libraries corresponding <br />
to C libraries?]]></description>
			<content:encoded><![CDATA[The Rule 18-0-1 of the MISRA-C++:2008 prohibits developers from using <br />
C libraries entirely. At the same time, the 'Rationale' section of this <br />
rule admits the use of the C++ libraries which correspond to C libraries.<br />
<br />
Many of the C++ libraries corresponding to C libraries are defined<br />
as the C libraries surrounded by the std namespace. For the reason, <br />
we think even if the C++ libraries corresponding to C libraries<br />
are used, it is impossible to avoid such vulnerability C libraries<br />
have as undefined behavior and unspecified behavior.<br />
<br />
Why does the Rule 18-0-1 admit the use of the C++ libraries corresponding <br />
to C libraries?]]></content:encoded>
		</item>
	</channel>
</rss>