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

Username
  

Password
  





  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

  12.1 and for-loops
Posted by: gs - 14-05-2008, 06:48 PM - Forum: 6.12 Expressions - Replies (2)

Given the code:

Code:
void f()
    {
    int i, j;
    for( i =0, j = 0; i < 10; i++, j++ ) {}
    }
does rule 12.1 'advise' (instead of 'require') I place '()' around the for-loop initializers? In other words, to what extent does this rule apply in the head of a for-loop? The precedence relied on is the precedence of the '=' operator with respect to the ',' operator.

Print this item

  12.6 boolean expression assigned to int example
Posted by: pkruk - 14-05-2008, 09:15 AM - Forum: MISRA-C:2004 Exemplar Suite - Replies (1)

Code:
uint16_t mc2_1206_x;
   uint16_t mc2_1206_y;
   uint16_t mc2_1206_z;
   mc2_1206_x = ( mc2_1206_y == mc2_1206_z ); /* Not compliant - mc2_1206_x is not effectively boolean */

This code has been marked as violation of rule 12.6 but I fail to see why. There are no (&&, || and !) operators so the first part of the rule does not apply. The boolean expression is used as operand of "=" so the second part of the rule is complied to as well.
Please correct me if I'm wrong.

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,309
» Latest member: 1fuhd
» Forum threads: 1,066
» Forum posts: 2,933

Full Statistics

Online Users
There are currently 98 online users.
» 0 Member(s) | 94 Guest(s)
Bing, Facebook, Google, UptimeRobot

Latest Threads
13.2 Was TC2 correctly ap...
Forum: 8.13 Side effects
Last Post: misra-c
08-10-2026, 12:47 PM
» Replies: 1
» Views: 624
20.12 Does the stringific...
Forum: 8.20 Preprocessing directives
Last Post: misra-c
08-10-2026, 12:40 PM
» Replies: 1
» Views: 554
13.3 Should side effects ...
Forum: 8.13 Side effects
Last Post: misra-c
08-10-2026, 12:37 PM
» Replies: 1
» Views: 426
11.6 pointer to pointer t...
Forum: 8.11 Pointer type conversions
Last Post: misra-c
08-10-2026, 12:21 PM
» Replies: 2
» Views: 1,032
What is the UTLR of -1?
Forum: 8.10 The essential type model
Last Post: misra-c
08-10-2026, 12:15 PM
» Replies: 1
» Views: 597
10.3 Clarify if narrower ...
Forum: 8.10 The essential type model
Last Post: misra-c
08-10-2026, 11:57 AM
» Replies: 1
» Views: 508
It 8.12 intended to be so...
Forum: 8.8 Declarations and defnitions
Last Post: misra-c
08-10-2026, 11:50 AM
» Replies: 1
» Views: 455
Rule 0.1.1 Example f4
Forum: 4.0 Language independent issues
Last Post: cgpzs
07-10-2026, 11:07 AM
» Replies: 3
» Views: 720
Rule 6-2-2 Usage of std::...
Forum: 6.6 Statements (C++)
Last Post: misra cpp
25-09-2026, 05:43 PM
» Replies: 1
» Views: 435
M5-0-4 switch over unscop...
Forum: 6.5 Expressions (C++)
Last Post: misra cpp
25-09-2026, 01:00 PM
» Replies: 3
» Views: 532