<?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.6 Basic concepts]]></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:23 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Rule 6.5.2: Missing exception for static class members?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1770</link>
			<pubDate>Tue, 02 Jun 2026 07:14:08 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6672">pwolf</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1770</guid>
			<description><![CDATA[The wording of rule 6.5.2 seems to imply that any entity with internal linkage may not be declared static, even though the static keyword “also has other uses”.<br />
With that interpretation, the rule would completely prohibit the use of static class members with internal linkage.<br />
<br />
For example, given this code snippet:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>static void F1() {} // 1<br />
<br />
namespace {<br />
<br />
static void F2() {} // 2<br />
<br />
class Klass {<br />
  public:<br />
    static void F3() {} // 3<br />
};<br />
<br />
} // namespace</code></div></div><br />
<br />
In cases 1 and 2, the static keyword is “inappropriate”. F1 should be declared inside the anonymous namespace instead and for F2 the static keyword could be simply dropped.<br />
F3 has internal linkage but the static is not used for linkage but to make the function a class function. Still, the amplification of rule 6.5.2 says that internal linkage of an entity is only appropriate if it’s not declared static, which F3 clearly is.<br />
<br />
Is that intentional? Should the wording be improved to make it clear that only static declarations which could affect linkage are considered?<br />
Or (to simplify static analysis) could an exception be added for static class members?]]></description>
			<content:encoded><![CDATA[The wording of rule 6.5.2 seems to imply that any entity with internal linkage may not be declared static, even though the static keyword “also has other uses”.<br />
With that interpretation, the rule would completely prohibit the use of static class members with internal linkage.<br />
<br />
For example, given this code snippet:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>static void F1() {} // 1<br />
<br />
namespace {<br />
<br />
static void F2() {} // 2<br />
<br />
class Klass {<br />
  public:<br />
    static void F3() {} // 3<br />
};<br />
<br />
} // namespace</code></div></div><br />
<br />
In cases 1 and 2, the static keyword is “inappropriate”. F1 should be declared inside the anonymous namespace instead and for F2 the static keyword could be simply dropped.<br />
F3 has internal linkage but the static is not used for linkage but to make the function a class function. Still, the amplification of rule 6.5.2 says that internal linkage of an entity is only appropriate if it’s not declared static, which F3 clearly is.<br />
<br />
Is that intentional? Should the wording be improved to make it clear that only static declarations which could affect linkage are considered?<br />
Or (to simplify static analysis) could an exception be added for static class members?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule about extern "C" and missing exceptions]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1768</link>
			<pubDate>Mon, 04 May 2026 16:24:26 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5871">kth</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1768</guid>
			<description><![CDATA[Currently, MISRA C++:2023 mentions "extern C" as part of the following rules:<ul class="mycode_list"><li>title of Rule 6.0.3 (The only declarations in the global namespace should be main, namespace declarations and <span style="font-weight: bold;" class="mycode_b">extern "C"</span> declarations),<br />
</li>
<li>exception 2 of Rule 10.2.1,<br />
</li>
<li>amplification and rationale of Rule 18.4.1 and<br />
</li>
<li>as part of different examples (e.g., in Rule 19.0.3)<br />
</li>
</ul>
<br />
However, until now there is no rule provided that limits the keywords etc. can be "safely" used inside of an extern "C" block.<br />
<br />
Wouldn't that be helpful?<br />
<br />
Examples:<ul class="mycode_list"><li>what happens when I define a namespace inside of an extern "C" block?<br />
</li>
<li>what happens when I define or declare (accidentally) a class in an extern "C" block?<br />
</li>
<li>what happens when I use a C++ reference in a function signature like "int foo(int&amp; in_out)"?<br />
</li>
<li>Basics: the C compiler does not know extern "C". Consequently, it should be surrounded by ´<span style="color: #000000;" class="mycode_color"><span style="font-family: Consolas, 'Liberation Mono', Courier, monospace, Consolas, 'Courier New', monospace;" class="mycode_font"><span style="color: #0000ff;" class="mycode_color">#ifdef</span> __cplusplus</span></span>´ and ´<span style="color: #000000;" class="mycode_color"><span style="font-family: Consolas, 'Liberation Mono', Courier, monospace, Consolas, 'Courier New', monospace;" class="mycode_font"><span style="color: #0000ff;" class="mycode_color">#endif</span></span></span>´.<br />
</li>
<li>...<br />
</li>
</ul>
<br />
What about exceptions for extern "C" in the rules<ul class="mycode_list"><li>11.3.1 (Variables of array type should not be declared) as in an extern C block a std::array is not available.<br />
</li>
<li>10.2.2 (Unscoped enumerations should not be declared) - notice that for 10.2.1 an exception si defined<br />
</li>
</ul>
<br />
Code example (<a href="https://godbolt.org/z/EG7Y9dxdh" target="_blank" rel="noopener" class="mycode_url">https://godbolt.org/z/EG7Y9dxdh</a>):<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>// some header.h - shared between C and C++<br />
<br />
#ifdef __cplusplus<br />
#include &lt;cstdint&gt;<br />
#else<br />
#include &lt;stdint.h&gt;<br />
#endif<br />
 <br />
#ifdef __cplusplus<br />
extern "C" {<br />
#endif<br />
<br />
  typedef int MyInt;  /* likely OK */<br />
<br />
  void foo();  /* likely not OK */<br />
<br />
  struct X { int a; };  /* is this OK? */  <br />
<br />
  struct Y { int32_t b; };  /* or this? */  <br />
<br />
  struct Z { char c[3]; };  /* or this? */  <br />
<br />
  namespace dummy {  /* and this? */<br />
  <br />
    class C {  /* or this - note: maybe the #ifdes __cplusplus guard is missing ...  */<br />
    public:<br />
      int val{2};<br />
    };<br />
<br />
  }<br />
<br />
#ifdef __cplusplus<br />
}<br />
#endif<br />
<br />
<br />
// c++ code<br />
<br />
int main() {<br />
  <br />
  dummy::C c1;<br />
<br />
  return c1.val;<br />
}</code></div></div>]]></description>
			<content:encoded><![CDATA[Currently, MISRA C++:2023 mentions "extern C" as part of the following rules:<ul class="mycode_list"><li>title of Rule 6.0.3 (The only declarations in the global namespace should be main, namespace declarations and <span style="font-weight: bold;" class="mycode_b">extern "C"</span> declarations),<br />
</li>
<li>exception 2 of Rule 10.2.1,<br />
</li>
<li>amplification and rationale of Rule 18.4.1 and<br />
</li>
<li>as part of different examples (e.g., in Rule 19.0.3)<br />
</li>
</ul>
<br />
However, until now there is no rule provided that limits the keywords etc. can be "safely" used inside of an extern "C" block.<br />
<br />
Wouldn't that be helpful?<br />
<br />
Examples:<ul class="mycode_list"><li>what happens when I define a namespace inside of an extern "C" block?<br />
</li>
<li>what happens when I define or declare (accidentally) a class in an extern "C" block?<br />
</li>
<li>what happens when I use a C++ reference in a function signature like "int foo(int&amp; in_out)"?<br />
</li>
<li>Basics: the C compiler does not know extern "C". Consequently, it should be surrounded by ´<span style="color: #000000;" class="mycode_color"><span style="font-family: Consolas, 'Liberation Mono', Courier, monospace, Consolas, 'Courier New', monospace;" class="mycode_font"><span style="color: #0000ff;" class="mycode_color">#ifdef</span> __cplusplus</span></span>´ and ´<span style="color: #000000;" class="mycode_color"><span style="font-family: Consolas, 'Liberation Mono', Courier, monospace, Consolas, 'Courier New', monospace;" class="mycode_font"><span style="color: #0000ff;" class="mycode_color">#endif</span></span></span>´.<br />
</li>
<li>...<br />
</li>
</ul>
<br />
What about exceptions for extern "C" in the rules<ul class="mycode_list"><li>11.3.1 (Variables of array type should not be declared) as in an extern C block a std::array is not available.<br />
</li>
<li>10.2.2 (Unscoped enumerations should not be declared) - notice that for 10.2.1 an exception si defined<br />
</li>
</ul>
<br />
Code example (<a href="https://godbolt.org/z/EG7Y9dxdh" target="_blank" rel="noopener" class="mycode_url">https://godbolt.org/z/EG7Y9dxdh</a>):<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>// some header.h - shared between C and C++<br />
<br />
#ifdef __cplusplus<br />
#include &lt;cstdint&gt;<br />
#else<br />
#include &lt;stdint.h&gt;<br />
#endif<br />
 <br />
#ifdef __cplusplus<br />
extern "C" {<br />
#endif<br />
<br />
  typedef int MyInt;  /* likely OK */<br />
<br />
  void foo();  /* likely not OK */<br />
<br />
  struct X { int a; };  /* is this OK? */  <br />
<br />
  struct Y { int32_t b; };  /* or this? */  <br />
<br />
  struct Z { char c[3]; };  /* or this? */  <br />
<br />
  namespace dummy {  /* and this? */<br />
  <br />
    class C {  /* or this - note: maybe the #ifdes __cplusplus guard is missing ...  */<br />
    public:<br />
      int val{2};<br />
    };<br />
<br />
  }<br />
<br />
#ifdef __cplusplus<br />
}<br />
#endif<br />
<br />
<br />
// c++ code<br />
<br />
int main() {<br />
  <br />
  dummy::C c1;<br />
<br />
  return c1.val;<br />
}</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6.0.3 and extern "C"]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1767</link>
			<pubDate>Mon, 04 May 2026 15:12:09 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5871">kth</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1767</guid>
			<description><![CDATA[Rule 6.0.3 has the title <br />
<blockquote class="mycode_quote"><cite>Quote:</cite>The only declarations in the global namespace should be main, namespace declarations and <span style="font-weight: bold;" class="mycode_b">extern "C" declarations</span></blockquote>
<br />
However, with the current MISRA C++:2023 version the amplification does not contain details about the <span style="font-weight: bold;" class="mycode_b">extern "C" declarations </span>and there are no  examples that use  an extern "C" block.<br />
<br />
My question first question: is it OK to use typdefs in extern "C" blocks and also in the global namespace to be able to share these typdefs between C and C++ code?<br />
<br />
Example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#ifdef __cplusplus<br />
#include &lt;cstdint&gt;<br />
#else<br />
#include &lt;stdint.h&gt;<br />
#endif<br />
<br />
#ifdef __cplusplus<br />
extern "C" {<br />
#endif<br />
<br />
typedef uint16_t AddressType_t;  /* Compliant? (to be able to share typdefs in C and C++ code this is OK) */ <br />
<br />
void foo();                      /* Compliant? ('foo' needs C linkage and it is OK to have a C function in the global namespace) */<br />
<br />
#ifdef __cplusplus<br />
}<br />
#endif</code></div></div><br />
<br />
Second question: As the rule explicitly mentions <span style="font-weight: bold;" class="mycode_b">extern "C" <span style="font-style: italic;" class="mycode_i">declarations</span></span> - what else is allowed or not allowed? (What about, e.g., struct definitions or function definitions?)]]></description>
			<content:encoded><![CDATA[Rule 6.0.3 has the title <br />
<blockquote class="mycode_quote"><cite>Quote:</cite>The only declarations in the global namespace should be main, namespace declarations and <span style="font-weight: bold;" class="mycode_b">extern "C" declarations</span></blockquote>
<br />
However, with the current MISRA C++:2023 version the amplification does not contain details about the <span style="font-weight: bold;" class="mycode_b">extern "C" declarations </span>and there are no  examples that use  an extern "C" block.<br />
<br />
My question first question: is it OK to use typdefs in extern "C" blocks and also in the global namespace to be able to share these typdefs between C and C++ code?<br />
<br />
Example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#ifdef __cplusplus<br />
#include &lt;cstdint&gt;<br />
#else<br />
#include &lt;stdint.h&gt;<br />
#endif<br />
<br />
#ifdef __cplusplus<br />
extern "C" {<br />
#endif<br />
<br />
typedef uint16_t AddressType_t;  /* Compliant? (to be able to share typdefs in C and C++ code this is OK) */ <br />
<br />
void foo();                      /* Compliant? ('foo' needs C linkage and it is OK to have a C function in the global namespace) */<br />
<br />
#ifdef __cplusplus<br />
}<br />
#endif</code></div></div><br />
<br />
Second question: As the rule explicitly mentions <span style="font-weight: bold;" class="mycode_b">extern "C" <span style="font-style: italic;" class="mycode_i">declarations</span></span> - what else is allowed or not allowed? (What about, e.g., struct definitions or function definitions?)]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6.9.1 and (possibly) qualified identifiers / name lookup / namespaces]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1766</link>
			<pubDate>Fri, 24 Apr 2026 14:10:30 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6542">ckaiser</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1766</guid>
			<description><![CDATA[Hello,<br />
<br />
We are wondering how Rule 6.9.1 shall be understood when namespaces and name lookups are involved.<br />
Rule's rationale is about avoiding confusion. But, especially, the examples only address very basic (mis)uses, i.e., using obviously different type (alias) names in (re-)declarations. Very C-like...<br />
<br />
It is unclear, when it comes to (namespace) qualification and (re-)introducing names into namespaces or scopes.<br />
Under those conditions, it becomes fuzzy what is meant with "the same type alias": Is it just the spelling of the name (including qualification)? Is it the definition, i.e. resulting the underlying type? Or, is it the same qualified name (regardless how it was spelled in code - i.e., whether and how it was qualified)?<br />
Maybe, it even is (or should be) out of scope of rule 6.9.1?<br />
<br />
<br />
Example:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>namespace n {<br />
 struct S {};<br />
 using Alias = S;<br />
 Alias foo(); // (0)<br />
 S bar();<br />
}<br />
<br />
auto n::foo() -&gt; Alias; // (1)<br />
n::Alias n::foo(); // (2) with leading return type I have to use the namespace.<br />
<br />
using Alias = n::Alias;<br />
auto n::foo() -&gt; Alias; // (3)<br />
Alias n::foo(); // (4)<br />
<br />
namespace m {<br />
 class Klass {<br />
 public:<br />
    using S = n::S;<br />
    using Alias = n::S;<br />
    friend Alias n::foo(); // (5)<br />
    friend S n::bar(); // (6)<br />
    explicit Klass(n::S const&amp;);<br />
};<br />
<br />
using n::S;<br />
auto Klass(S const&amp;); // (7)<br />
}</code></div></div>First observation: It doesn't seem to be always about type aliases, but about the question, wich type (name) will be eventually used. This might be out of scope of Rule 6.9.1, but it is still related to developer's expectation / possible confusion.<br />
<br />
Note: to keep the examples simple, I'd judge "compliance" always only considering any difference to the initial declaration, e.g., (0).<br />
(In practice, one violating declaration probably would cause the whole set of declarations being not compliant.)<br />
<br />
(1): Is most definitely compliant, as both indeed use the very same type alias, in all respects.<br />
(2): Compliant? It "names" the same alias, but it is "spelled" (i.e., it looks) differently. Might lead to confusion?<br />
(3): Compliant? Maybe; which alias will be used? Should it matter in this case?<br />
(4): Compliant? Same (unqualified) name ist used, but in the end it is a different alias, still resulting in the same type. Regarding the underlying type, one could argue, it is still the same alias.<br />
(5): Compliant? Similar to (4); just to demonstrate a friend declaration.<br />
(6): Compliant? Original declaration didn't even use a type alias - maybe, not even in scope? Still same "name".<br />
(7): Compliant? IMO, actually not in scope, because type aliases are not used in any declaration of that entity.<br />
<br />
<br />
Personally, I don't have a strong opinion on that. I just found declarations of those kinds in our codebase. Thus, I'm asking for clarification.<br />
IMHO, using same names (qualified or unqualified) seems to match expectations it <span style="font-style: italic;" class="mycode_i">could </span>be okay, as long as they do result in same types.<br />
Mixing different qualifications within one scope (class or namespace) is quite confusing as well (such as (1) and (2), even though namespace qualification is required for (2))<br />
<br />
Thank you very much,<br />
Best regards.]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
We are wondering how Rule 6.9.1 shall be understood when namespaces and name lookups are involved.<br />
Rule's rationale is about avoiding confusion. But, especially, the examples only address very basic (mis)uses, i.e., using obviously different type (alias) names in (re-)declarations. Very C-like...<br />
<br />
It is unclear, when it comes to (namespace) qualification and (re-)introducing names into namespaces or scopes.<br />
Under those conditions, it becomes fuzzy what is meant with "the same type alias": Is it just the spelling of the name (including qualification)? Is it the definition, i.e. resulting the underlying type? Or, is it the same qualified name (regardless how it was spelled in code - i.e., whether and how it was qualified)?<br />
Maybe, it even is (or should be) out of scope of rule 6.9.1?<br />
<br />
<br />
Example:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>namespace n {<br />
 struct S {};<br />
 using Alias = S;<br />
 Alias foo(); // (0)<br />
 S bar();<br />
}<br />
<br />
auto n::foo() -&gt; Alias; // (1)<br />
n::Alias n::foo(); // (2) with leading return type I have to use the namespace.<br />
<br />
using Alias = n::Alias;<br />
auto n::foo() -&gt; Alias; // (3)<br />
Alias n::foo(); // (4)<br />
<br />
namespace m {<br />
 class Klass {<br />
 public:<br />
    using S = n::S;<br />
    using Alias = n::S;<br />
    friend Alias n::foo(); // (5)<br />
    friend S n::bar(); // (6)<br />
    explicit Klass(n::S const&amp;);<br />
};<br />
<br />
using n::S;<br />
auto Klass(S const&amp;); // (7)<br />
}</code></div></div>First observation: It doesn't seem to be always about type aliases, but about the question, wich type (name) will be eventually used. This might be out of scope of Rule 6.9.1, but it is still related to developer's expectation / possible confusion.<br />
<br />
Note: to keep the examples simple, I'd judge "compliance" always only considering any difference to the initial declaration, e.g., (0).<br />
(In practice, one violating declaration probably would cause the whole set of declarations being not compliant.)<br />
<br />
(1): Is most definitely compliant, as both indeed use the very same type alias, in all respects.<br />
(2): Compliant? It "names" the same alias, but it is "spelled" (i.e., it looks) differently. Might lead to confusion?<br />
(3): Compliant? Maybe; which alias will be used? Should it matter in this case?<br />
(4): Compliant? Same (unqualified) name ist used, but in the end it is a different alias, still resulting in the same type. Regarding the underlying type, one could argue, it is still the same alias.<br />
(5): Compliant? Similar to (4); just to demonstrate a friend declaration.<br />
(6): Compliant? Original declaration didn't even use a type alias - maybe, not even in scope? Still same "name".<br />
(7): Compliant? IMO, actually not in scope, because type aliases are not used in any declaration of that entity.<br />
<br />
<br />
Personally, I don't have a strong opinion on that. I just found declarations of those kinds in our codebase. Thus, I'm asking for clarification.<br />
IMHO, using same names (qualified or unqualified) seems to match expectations it <span style="font-style: italic;" class="mycode_i">could </span>be okay, as long as they do result in same types.<br />
Mixing different qualifications within one scope (class or namespace) is quite confusing as well (such as (1) and (2), even though namespace qualification is required for (2))<br />
<br />
Thank you very much,<br />
Best regards.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6.7.1 and local declarations with external linkage]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1763</link>
			<pubDate>Tue, 27 Jan 2026 15:26:01 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6503">karos</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1763</guid>
			<description><![CDATA[Is this rule intended to apply to variable declarations of external linkage? For example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int main()<br />
{<br />
    extern int var;<br />
    var = 4;<br />
}</code></div></div><br />
'var' is declared at block scope, refers to an object of static storage duration and is not const-qualified. Hence, it appears to be non-compliant with this rule.<br />
<br />
However, my feeling is that it does not really fit the rationale of the rule as it does not add persistent state to the function (this declaration cannot be a definition, so some definition of var must exist outside of main). One could argue that var is effectively not local to the function containing the declaration.<br />
<br />
Can you please clarify?<br />
<br />
PS: I'm aware that such code does not comply with other rules as well (e.g. 6.7.2).]]></description>
			<content:encoded><![CDATA[Is this rule intended to apply to variable declarations of external linkage? For example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int main()<br />
{<br />
    extern int var;<br />
    var = 4;<br />
}</code></div></div><br />
'var' is declared at block scope, refers to an object of static storage duration and is not const-qualified. Hence, it appears to be non-compliant with this rule.<br />
<br />
However, my feeling is that it does not really fit the rationale of the rule as it does not add persistent state to the function (this declaration cannot be a definition, so some definition of var must exist outside of main). One could argue that var is effectively not local to the function containing the declaration.<br />
<br />
Can you please clarify?<br />
<br />
PS: I'm aware that such code does not comply with other rules as well (e.g. 6.7.2).]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Distinction between rule 6.8.1 and 6.8.4]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1761</link>
			<pubDate>Thu, 15 Jan 2026 10:41:27 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5889">hahn</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1761</guid>
			<description><![CDATA[Hi,<br />
<br />
rule 6.8.4 covers a decidable subset of rule 6.8.1.<br />
The scope of rule 6.8.4 is limited by the phrase "explicitly designates".<br />
I am not sure about the exact meaning of "explicitly designates" and I hope for a clarification.<br />
<br />
Here is a list of cases I am not sure about.<br />
I put my interpretation of "explicitly designates" as comments in the code.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct A {<br />
  int m_a;<br />
  int m_b;<br />
<br />
  const int &amp;a() const { // non-compliant - m_a as subobject explicitly designated<br />
    return m_a;<br />
  }<br />
  <br />
  const int &amp;b() const { // compliant as rule does not apply? Or is ++m_a an explicit designation of subobject m_a?<br />
    return ++m_a;<br />
  }<br />
  <br />
  const int &amp;c() const { // compliant as rule does not apply? Or is this expression an explicit designation of m_a/m_b too?<br />
    return cond ? m_a : m_b;<br />
  }<br />
  <br />
  const int &amp;d() const { // compliant as rule does not apply? calling a() somehow designates m_a, but not "explicitly", right?<br />
    return a();<br />
  }<br />
<br />
  const int *e() const { // compliant as rule does not apply as shown by examples for rule 6.8.4<br />
    const int *p = &amp;m_a;<br />
    return p;<br />
  }<br />
};</code></div></div><br />
All functions clearly violate the undecidable rule 6.8.1, but which functions should violate 6.8.4 too?<br />
<br />
Thanks in advance.]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
rule 6.8.4 covers a decidable subset of rule 6.8.1.<br />
The scope of rule 6.8.4 is limited by the phrase "explicitly designates".<br />
I am not sure about the exact meaning of "explicitly designates" and I hope for a clarification.<br />
<br />
Here is a list of cases I am not sure about.<br />
I put my interpretation of "explicitly designates" as comments in the code.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct A {<br />
  int m_a;<br />
  int m_b;<br />
<br />
  const int &amp;a() const { // non-compliant - m_a as subobject explicitly designated<br />
    return m_a;<br />
  }<br />
  <br />
  const int &amp;b() const { // compliant as rule does not apply? Or is ++m_a an explicit designation of subobject m_a?<br />
    return ++m_a;<br />
  }<br />
  <br />
  const int &amp;c() const { // compliant as rule does not apply? Or is this expression an explicit designation of m_a/m_b too?<br />
    return cond ? m_a : m_b;<br />
  }<br />
  <br />
  const int &amp;d() const { // compliant as rule does not apply? calling a() somehow designates m_a, but not "explicitly", right?<br />
    return a();<br />
  }<br />
<br />
  const int *e() const { // compliant as rule does not apply as shown by examples for rule 6.8.4<br />
    const int *p = &amp;m_a;<br />
    return p;<br />
  }<br />
};</code></div></div><br />
All functions clearly violate the undecidable rule 6.8.1, but which functions should violate 6.8.4 too?<br />
<br />
Thanks in advance.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6.9.2: Are non-top level users of basic types permitted in an alias?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1754</link>
			<pubDate>Thu, 09 Oct 2025 23:06:20 +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=1754</guid>
			<description><![CDATA[Hi,<br />
<br />
The first exception for Rule 6.9.2 permits the use of a basic type to define a type alias.  I guess the wording may be more broad than intended.  For example,is the following permitted?<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#include &lt;list&gt;<br />
typedef std::list&lt;int&gt; int_list;</code></div></div><br />
Thank you!]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
The first exception for Rule 6.9.2 permits the use of a basic type to define a type alias.  I guess the wording may be more broad than intended.  For example,is the following permitted?<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#include &lt;list&gt;<br />
typedef std::list&lt;int&gt; int_list;</code></div></div><br />
Thank you!]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6.8.4 clarification of amplification]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1747</link>
			<pubDate>Fri, 08 Aug 2025 08:06:08 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5871">kth</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1747</guid>
			<description><![CDATA[The amplification of rule 6.8.4 leads with this sentence to clarify to which member functions this rule applies:<br />
<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>This rule applies to member functions with reference or pointer return type, where, in the definition of the function, at least one<br />
return expression explicitly designates this, *this or a subobject of *this.</blockquote>
<br />
The usage of the word “designates” here is ambiguous. <br />
Does it mean the expression . . .<br />
<br />
<ol type="1" class="mycode_list"><li> . . . is (or evaluates to something that is) this, *this or a subobject of *this?<br />
</li>
<li> . . . refers/points to (or evaluates to something that refers/points to) this, *this or a subobject of *this?<br />
</li>
<li> . . . contains this, *this or a subobject of *this in any shape or form?<br />
</li>
<li>A combination of the above?<br />
</li>
</ol>
<br />
Depending on which interpretation is true, the following code examples are either <br />
compliant or non-compliant:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>class A {<br />
std::int32_t data_;<br />
public:<br />
// returns a pointer to data member<br />
std::int32_t const* Get() const { return &amp;data_; }<br />
};<br />
<br />
class B { <br />
std::int32_t* ptr_;<br />
public:<br />
// returns data member which is a pointer to an<br />
// object with lifecycle independent of "this" <br />
std::int32_t* Get() const { return ptr_; }<br />
};<br />
<br />
class C { <br />
std::int32_t idx_;<br />
public:<br />
// returns unrelated pointer based on data member<br />
float const* Get(std::array&lt;float,10&gt; const&amp; data) const { return &amp;data[idx_]; }<br />
};</code></div></div><br />
The intent of the rule seem to support meaning number 2, which would mean only A::Get is non-compliant. <br />
If that is the case, we suggest to replace “designates” with a less ambiguous phrase, e.g. “references/points to” or to explain more clearly what is meant in the amplification. <br />
In addition, clarifying examples for these cases would be helpful.]]></description>
			<content:encoded><![CDATA[The amplification of rule 6.8.4 leads with this sentence to clarify to which member functions this rule applies:<br />
<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>This rule applies to member functions with reference or pointer return type, where, in the definition of the function, at least one<br />
return expression explicitly designates this, *this or a subobject of *this.</blockquote>
<br />
The usage of the word “designates” here is ambiguous. <br />
Does it mean the expression . . .<br />
<br />
<ol type="1" class="mycode_list"><li> . . . is (or evaluates to something that is) this, *this or a subobject of *this?<br />
</li>
<li> . . . refers/points to (or evaluates to something that refers/points to) this, *this or a subobject of *this?<br />
</li>
<li> . . . contains this, *this or a subobject of *this in any shape or form?<br />
</li>
<li>A combination of the above?<br />
</li>
</ol>
<br />
Depending on which interpretation is true, the following code examples are either <br />
compliant or non-compliant:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>class A {<br />
std::int32_t data_;<br />
public:<br />
// returns a pointer to data member<br />
std::int32_t const* Get() const { return &amp;data_; }<br />
};<br />
<br />
class B { <br />
std::int32_t* ptr_;<br />
public:<br />
// returns data member which is a pointer to an<br />
// object with lifecycle independent of "this" <br />
std::int32_t* Get() const { return ptr_; }<br />
};<br />
<br />
class C { <br />
std::int32_t idx_;<br />
public:<br />
// returns unrelated pointer based on data member<br />
float const* Get(std::array&lt;float,10&gt; const&amp; data) const { return &amp;data[idx_]; }<br />
};</code></div></div><br />
The intent of the rule seem to support meaning number 2, which would mean only A::Get is non-compliant. <br />
If that is the case, we suggest to replace “designates” with a less ambiguous phrase, e.g. “references/points to” or to explain more clearly what is meant in the amplification. <br />
In addition, clarifying examples for these cases would be helpful.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6.7.2 variable templates]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1742</link>
			<pubDate>Thu, 24 Jul 2025 18:55:00 +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=1742</guid>
			<description><![CDATA[Is the following considered to be compliant:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>template &lt;typename T&gt;<br />
T var = 42;</code></div></div><br />
<br />
By itself it seems not to be in the spirit of the rule since there's no "const" in the declaration.  But what if the only instantiation is something like:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int foo() { return var&lt;const int&gt;; }</code></div></div><br />
Thank you.]]></description>
			<content:encoded><![CDATA[Is the following considered to be compliant:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>template &lt;typename T&gt;<br />
T var = 42;</code></div></div><br />
<br />
By itself it seems not to be in the spirit of the rule since there's no "const" in the declaration.  But what if the only instantiation is something like:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int foo() { return var&lt;const int&gt;; }</code></div></div><br />
Thank you.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6.2.1 weak linkage]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1727</link>
			<pubDate>Fri, 28 Feb 2025 09:33:42 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5889">hahn</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1727</guid>
			<description><![CDATA[Dear MISRA group,<br />
<br />
I have a question regarding the interpretation of the one-definition-rule in the presence of weak linkage (i.e. __attribute__((weak))).<br />
In particular, is it considered a violation of the odr rule/rule 6.2.1 if a function with "strong" linkage "overrides" a function with "weak" linkage (as typically found in (standard) libraries)?<br />
<br />
A special case within this discussion are global allocation and deallocation functions. The C++ standard calls them explicitly "replaceable".<br />
Implementation-wise in any standard library I know, this is expressed by the weak linkage attribute.<br />
Since the standard allows these few functions to be replaced explicitly, I conclude this does not constitute a violation of the one-definition-rule.<br />
<br />
But how about any other weak-linkage function?<br />
<br />
Thanks in advance!]]></description>
			<content:encoded><![CDATA[Dear MISRA group,<br />
<br />
I have a question regarding the interpretation of the one-definition-rule in the presence of weak linkage (i.e. __attribute__((weak))).<br />
In particular, is it considered a violation of the odr rule/rule 6.2.1 if a function with "strong" linkage "overrides" a function with "weak" linkage (as typically found in (standard) libraries)?<br />
<br />
A special case within this discussion are global allocation and deallocation functions. The C++ standard calls them explicitly "replaceable".<br />
Implementation-wise in any standard library I know, this is expressed by the weak linkage attribute.<br />
Since the standard allows these few functions to be replaced explicitly, I conclude this does not constitute a violation of the one-definition-rule.<br />
<br />
But how about any other weak-linkage function?<br />
<br />
Thanks in advance!]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6.2.1: non-inline constexpr variables in headers?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1716</link>
			<pubDate>Fri, 22 Nov 2024 10:11:39 +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=1716</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>// foo.h<br />
constexpr int kFoo = 123;<br />
<br />
inline int foo(int x)<br />
{ <br />
  return x * kFoo;<br />
}<br />
<br />
// tu1.cpp<br />
#include "foo.h"<br />
int tu1() { return foo(1); }<br />
<br />
// tu2.cpp<br />
#include "foo.h"<br />
int tu2() { return foo(2); }</code></div></div><br />
Does the function "foo" violate Rule 6.2.1 in this context, given that kFoo is not a C++17 inline variable? <br />
Or would it violate 6.2.1 only if kFoo were ODR-used (for example, passed by reference)?<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>// foo.h<br />
constexpr int kFoo = 123;<br />
<br />
inline int foo(int x)<br />
{ <br />
  return x * kFoo;<br />
}<br />
<br />
// tu1.cpp<br />
#include "foo.h"<br />
int tu1() { return foo(1); }<br />
<br />
// tu2.cpp<br />
#include "foo.h"<br />
int tu2() { return foo(2); }</code></div></div><br />
Does the function "foo" violate Rule 6.2.1 in this context, given that kFoo is not a C++17 inline variable? <br />
Or would it violate 6.2.1 only if kFoo were ODR-used (for example, passed by reference)?<br />
<br />
Thanks!]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6.7.1 and thread storage duration]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1702</link>
			<pubDate>Tue, 10 Sep 2024 18:40:41 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=6099">rg99</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1702</guid>
			<description><![CDATA[Is Rule 6.7.1 intended to apply to local variables with thread storage duration?  For example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>typedef int int32_t;<br />
<br />
void foo() {<br />
    static int32_t var1{0};        // Non-compliant<br />
    thread_local int32_t var2{0};  // Compliant ???<br />
    /* ... */<br />
}</code></div></div><br />
<br />
While the rule specifically references "static storage duration" it is not clear what the intended impact of this rule is with respect to "thread storage duration" variables.  While local variables with thread storage duration do not suffer the same intrinsically thread-unsafe characteristics as those with static storage duration, the provided Rationale still applies.  In particular, they decrease comprehensibility, introduce temporal coupling, and can result in (reentrant) data races.]]></description>
			<content:encoded><![CDATA[Is Rule 6.7.1 intended to apply to local variables with thread storage duration?  For example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>typedef int int32_t;<br />
<br />
void foo() {<br />
    static int32_t var1{0};        // Non-compliant<br />
    thread_local int32_t var2{0};  // Compliant ???<br />
    /* ... */<br />
}</code></div></div><br />
<br />
While the rule specifically references "static storage duration" it is not clear what the intended impact of this rule is with respect to "thread storage duration" variables.  While local variables with thread storage duration do not suffer the same intrinsically thread-unsafe characteristics as those with static storage duration, the provided Rationale still applies.  In particular, they decrease comprehensibility, introduce temporal coupling, and can result in (reentrant) data races.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6.9.2: Unclear interpretation about "char"]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1701</link>
			<pubDate>Tue, 03 Sep 2024 07:52:17 +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=1701</guid>
			<description><![CDATA[Hi,<br />
<br />
Rule 6.9.2 says it applies to "integral types constructed using the keywords char, ...". <br />
But it also says "it does not apply to the use of plain char".<br />
<br />
This is confusing - is "char" allowed or not? Can you provide an example that shows where "char" is allowed and where it's not? I cannot find any in the rule explanation.<br />
<br />
Thanks!]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
Rule 6.9.2 says it applies to "integral types constructed using the keywords char, ...". <br />
But it also says "it does not apply to the use of plain char".<br />
<br />
This is confusing - is "char" allowed or not? Can you provide an example that shows where "char" is allowed and where it's not? I cannot find any in the rule explanation.<br />
<br />
Thanks!]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6.9.2: Missing exception for user-defined literals?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1673</link>
			<pubDate>Mon, 26 Feb 2024 19:59:43 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=5871">kth</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1673</guid>
			<description><![CDATA[MISRA C++ rule 6.9.2 (The names of the standard signed integer types and standard unsigned integer types should not be used) defines two exceptions (shortened):<br />
1. for type aliases <br />
2. postfix operator, return type of main and argc of main.<br />
<br />
Currently, there is no exception for user-defined literals.<br />
<br />
However, the C++ standard defines as part of  [over.literal] §16.5.8.3:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>3 The declaration of a literal operator shall have a parameter-declaration-clause equivalent to one of the<br />
following:<br />
const char*<br />
unsigned long long int<br />
long double<br />
char<br />
wchar_t<br />
char16_t<br />
char32_t<br />
const char*, std::size_t<br />
const wchar_t*, std::size_t<br />
const char16_t*, std::size_t<br />
const char32_t*, std::size_t<br />
If a parameter has a default argument (11.3.6), the program is ill-formed.</code></div></div><br />
<br />
Is a exception for user-defined literals missing?]]></description>
			<content:encoded><![CDATA[MISRA C++ rule 6.9.2 (The names of the standard signed integer types and standard unsigned integer types should not be used) defines two exceptions (shortened):<br />
1. for type aliases <br />
2. postfix operator, return type of main and argc of main.<br />
<br />
Currently, there is no exception for user-defined literals.<br />
<br />
However, the C++ standard defines as part of  [over.literal] §16.5.8.3:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>3 The declaration of a literal operator shall have a parameter-declaration-clause equivalent to one of the<br />
following:<br />
const char*<br />
unsigned long long int<br />
long double<br />
char<br />
wchar_t<br />
char16_t<br />
char32_t<br />
const char*, std::size_t<br />
const wchar_t*, std::size_t<br />
const char16_t*, std::size_t<br />
const char32_t*, std::size_t<br />
If a parameter has a default argument (11.3.6), the program is ill-formed.</code></div></div><br />
<br />
Is a exception for user-defined literals missing?]]></content:encoded>
		</item>
	</channel>
</rss>