<?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.12 Special member functions (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:35 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Syntactic clarification of 12-8-1 wording]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1053</link>
			<pubDate>Thu, 24 Apr 2014 16:06:56 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=64">gs</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1053</guid>
			<description><![CDATA[Rule 12-8-1 states:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>A copy constructor shall only initialize its base classes and the non-static members of the class of which it is a member.</blockquote>
Does this sentence mean:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite> A copy constructor may only initialize and, when doing so, may only initialize its base classes and the non-static members of the class of which it is a member.</blockquote>
or<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>A copy constructor may do things other than initialization but, if it does initialize, it may only initialize its base classes and the non-static members of the class of which it is a member.</blockquote>
?]]></description>
			<content:encoded><![CDATA[Rule 12-8-1 states:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>A copy constructor shall only initialize its base classes and the non-static members of the class of which it is a member.</blockquote>
Does this sentence mean:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite> A copy constructor may only initialize and, when doing so, may only initialize its base classes and the non-static members of the class of which it is a member.</blockquote>
or<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>A copy constructor may do things other than initialization but, if it does initialize, it may only initialize its base classes and the non-static members of the class of which it is a member.</blockquote>
?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Example for Rule 12â€“1â€“1]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=604</link>
			<pubDate>Wed, 24 Dec 2008 11:34:08 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=368">pkruk</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=604</guid>
			<description><![CDATA[Hello, <br />
<br />
I'm not sure if the example for this rule is correct in one case. Simplified code:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>class B2<br />
{<br />
public:<br />
virtual ~B2 ( );<br />
B2 ( )<br />
{<br />
typeid ( B2 ); // Non-compliant<br />
}<br />
};</code></div></div><br />
Why is this typeid non compliant? It does not use objectâ€™s dynamic type so it should not be a violation of the rule. This is similar to using typeid on e.g. not polymorphic type, which is allowed by the rule. ISO/IEC 14882:2003(E) standard:<br />
<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>5.2.8<br />
3. When typeid is applied to an expression other than an lvalue of a polymorphic class type, the result<br />
refers to a type_info object representing the static type of the expression. [...]<br />
4. When typeid is applied to a type-id, the result refers to a type_info object representing the type of the<br />
type-id. [...]</blockquote>
]]></description>
			<content:encoded><![CDATA[Hello, <br />
<br />
I'm not sure if the example for this rule is correct in one case. Simplified code:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>class B2<br />
{<br />
public:<br />
virtual ~B2 ( );<br />
B2 ( )<br />
{<br />
typeid ( B2 ); // Non-compliant<br />
}<br />
};</code></div></div><br />
Why is this typeid non compliant? It does not use objectâ€™s dynamic type so it should not be a violation of the rule. This is similar to using typeid on e.g. not polymorphic type, which is allowed by the rule. ISO/IEC 14882:2003(E) standard:<br />
<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>5.2.8<br />
3. When typeid is applied to an expression other than an lvalue of a polymorphic class type, the result<br />
refers to a type_info object representing the static type of the expression. [...]<br />
4. When typeid is applied to a type-id, the result refers to a type_info object representing the type of the<br />
type-id. [...]</blockquote>
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Do implicitly generated copy-assignment operators count?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=578</link>
			<pubDate>Tue, 09 Sep 2008 17:31:22 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=64">gs</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=578</guid>
			<description><![CDATA[Rule 12-8-2 states:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>The copy assignment operator shall be declared protected or private in an abstract class.</blockquote>
Does this prohibition also include the implicitly generated copy assignment operator?  When implicitly generated, ISO C++, 12.8, p. 10, states:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>An implicitly-declared copy assignment operator is an inline public member of its class.</blockquote>
So, does the following code comply with rule 12-8-2:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>class A<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;virtual void b() = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;};</code></div></div>?]]></description>
			<content:encoded><![CDATA[Rule 12-8-2 states:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>The copy assignment operator shall be declared protected or private in an abstract class.</blockquote>
Does this prohibition also include the implicitly generated copy assignment operator?  When implicitly generated, ISO C++, 12.8, p. 10, states:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>An implicitly-declared copy assignment operator is an inline public member of its class.</blockquote>
So, does the following code comply with rule 12-8-2:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>class A<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;virtual void b() = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;};</code></div></div>?]]></content:encoded>
		</item>
	</channel>
</rss>