Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





  Rule 14–6–1 and injected-class-names
Posted by: James Widman - 03-07-2008, 04:56 PM - Forum: 6.14 Templates (C++) - Replies (3)

Hi all,

Rule 14–6–1 says:

"In a class template with a dependent base, any name
that may be found in that dependent base shall be
referred to using a qualified-id or this->"

But then the example code contains this line:

Code:
typename B::TYPE t2 = 0; // Compliant - explicit use base TYPE
But I don't think that's correct, because although TYPE is qualified, B is not. I think this line should be moved into A::f1() and commented with "Non-compliant: B is unqualified". And add the line:
Code:
typename ::B::TYPE t2 = 0; // Compliant - explicit use of B and of TYPE.
...to f2().

Here's an example where it makes a difference:
Code:
template  
struct B  {
    static void j();
};

namespace N {
    template  
        struct B {
            static void j();
        };

}

template  
struct A : public N::B {
    static void f1 ( ) {
        A::template B::j(); // compliant
        A::B::j(); // compliant
    }
    static void f2 ( ) {
        B::j(); // non-compliant
    }
};

void h() {
    A::f1(); // calls ::N::B::j() twice
    A::f2(); // calls ::B::j() once
}

Print this item

  int main() and rule 6.3
Posted by: Lundin - 23-06-2008, 01:23 PM - Forum: 6.6 Types - Replies (1)

I was wondering whether rule 6.3 applies to int main() or if this is should be a special exception? Ie should we write sint16_t main() or not?
Because if we state the width and signedness of main() we will suddenly make the app implementation-dependant and non-portable.

Also, ISO C strictly states that the return type shall be "int" on a hosted environment. One could interpret that as "it must be the primitive
data type int and no custom typedef".

Print this item

  Seeking Clarification for Required Rule 0-1-8
Posted by: gs - 20-06-2008, 04:23 PM - Forum: 6.0 Language independent issues (C++) - Replies (1)

MISRA C++ 0-1-8 (Required) states, "All functions with void return type shall have external side effect(s)." Quoting the rationale:

Quote: A function which does not return a value and which does not have external side effects will only consume time and will not contribute to the generation of any outputs, which may not meet developer expectations. The following are examples of external side effects:
• Reading or writing to a file, stream, etc.;
• Changing the value of a non local variable;
• Changing the value of an argument having reference type;
• Using a volatile object;
• Raising an exception.

So, what about this function:
Code:
void f()
    {
    try {
        throw 3;
    }
    catch( int )
        {}
    }

The above function raises an exception. However, as We see, the catch handler processes the exception within the same function and does "not contribute to the generation of any outputs". In such a case, does the function meet the requirements of 0-1-8?

Print this item

  Misra C Cross Reference
Posted by: IanStroud - 17-06-2008, 08:07 AM - Forum: C++ General - No Replies

Hi,

We have just purchased a copy of the Misra-C++ Guideline. Not surprisingly there is a lot of commonality with the Misra C guidelines but the rules have different numbers.

Is there a document that cross references the Rules between the two guidelines. In particular I would like to know:
-those rules in Misra C that do not appear in Misra C++
-those rules in Misra C++ that do not appear in Misra C
-rules that are common to both but have been amended slightly in the C++ guidelines

We have spent a lot of time going through the Misra C document seeing which Rules we think are worth adopting into our general coding standards and now wish to do the same with C++. Having a some cross reference would greatly assist this process.

thanks

Print this item

  Underlying type of unary minus operator (-var)
Posted by: pkruk - 09-06-2008, 12:19 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (2)

I have a question about underlying type of expressions involving unary minus operator. This is connected to 10.1 rule that disallows signed/unsigned conversions.

For example:

Code:
uint8_t  mc2_1209_u8a;
mc2_1209_u8a = -mc2_1209_u8a;

What is the underlying type of "-mc2_1209_u8a" expression? If it is unsigned then rule 10.1 is not violated; if it is signed then the rule is violated. (Of course this code is a violation of rule 12.9 anyway).

In my opinion the underlying type is still uint8 because C standard says in 6.5.3.3[3] (C99 cited):
Quote:The result of the unary - operator is the negative of its (promoted) operand.
The integer promotions are performed on the operand, and the result has the
promoted type.

This seems consistent with rule 12.9 which disallows using unary minus operator on unsigned operands.

Please correct me if I am wrong or if this was not the intention of MISRA rules.

Print this item

  http://www.misra-cpp.org/ ?
Posted by: bpaddock - 08-06-2008, 11:27 AM - Forum: C++ General - Replies (2)

What is http://www.misra-cpp.org/ meant to be about?
It is a dead link.

Print this item

  MISRA C++ forums
Posted by: david ward - 06-06-2008, 08:50 AM - Forum: C++ Announcements - Replies (1)

With the publication of MISRA C++, the discussion forums are available to ask questions. The MISRA C++ group will review these questions from time to time and if appropriate will post an official reply. Official replies concerning rule interpretations will be posted by the user "misra cpp".

Please note the following concerning the forums:

  • If you have a question about a specific rule, please post it in the appropriate subforum of "MISRA C++:2008 rules". The subforums are arranged according to the section numbers of the "Rules" chapter in MISRA C++. The rules are numbered xx-yy-zz, thus a question about a particular rule should be posted in the forum for Section 6.xx. For example if you have a question about Rule 6-6-1 it should be posted under Section 6.6 "Statements"
  • For all other questions about MISRA C++ use the "C++ general" forum

Print this item

  MISRA C++ published
Posted by: david ward - 06-06-2008, 08:42 AM - Forum: C++ Announcements - Replies (2)

MISRA is pleased to announce that MISRA C++ Guidelines for the use of the C++ language in critical systems was published on 5 June 2008. It is available in both hardcopy and PDF versions from our webstore.

Print this item

  Does 5.6 or 5.7 apply to block scope identifiers?
Posted by: gs - 15-05-2008, 03:30 PM - Forum: 6.5 Identifiers - Replies (3)

The rule reads:

Quote:No identifier name should be reused.

Regardless of scope, no identifier should be re-used across any files in the system. This rule incorporates the provisions of Rules 5.2, 5.3, 5.4, 5.5 and 5.6.

Does this advisory apply to block scope variables? The accompanying text says the rule incorporates the provisions of the other rules, but does not say if the rule is limited to just those provisions.

Rule 5.7 appears to constitute a stricter version of rule 5.6, which raises the question, "Does 5.6 apply to block scope variables?" as well.

Print this item

  20.1, 20.2 scopes
Posted by: pkruk - 15-05-2008, 01:08 PM - Forum: 6.20 Standard Libraries - Replies (1)

Is rule 20.1 limited to #define and #undef directives?
Is rule 20.2 limited only to identifiers already defined in standard library?

If this is true:

Code:
void errno();
/* errono is a reserved keyword and is already defined in standard library */
/* This code is a violation of rule 20.2 only  */

int __MyVariable();
/* __MyVariable is also a reserved keyword but is not defined in standard library */
/* This code is not a violation of 20.1 nor 20.2 */

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,171
» Latest member: stephanmuench
» Forum threads: 998
» Forum posts: 2,752

Full Statistics

Online Users
There are currently 254 online users.
» 0 Member(s) | 252 Guest(s)
Bing, Google

Latest Threads
Rule 6.2.1: non-inline co...
Forum: 4.6 Basic concepts
Last Post: cgpzs
22-11-2024, 10:11 AM
» Replies: 0
» Views: 37
Rule 0.1.2
Forum: 4.0 Language independent issues
Last Post: stephanmuench
21-11-2024, 01:12 PM
» Replies: 0
» Views: 46
A18-9-4
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
23-10-2024, 12:04 PM
» Replies: 2
» Views: 399
A8-4-5: are partial moves...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
22-10-2024, 02:03 PM
» Replies: 1
» Views: 339
model information blocks ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:27 PM
» Replies: 1
» Views: 4,459
MISRA AL SLSF - Rule 043I
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:11 PM
» Replies: 1
» Views: 8,876
MISRA AC EC guidelines
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:21 AM
» Replies: 4
» Views: 15,525
News on future releases
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:05 AM
» Replies: 1
» Views: 5,707
Signal naming convention ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 07:57 AM
» Replies: 1
» Views: 7,258
Rule 7.0.2: operator cons...
Forum: 4.7 Standard conversions
Last Post: karos
14-10-2024, 08:52 PM
» Replies: 2
» Views: 449