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

Username
  

Password
  





  Rule 3-2-3 and friend Declarations
Posted by: gs - 30-09-2010, 04:28 PM - Forum: 6.3 Basic concepts (C++) - Replies (1)

Am I correct in presuming rule 3-2-3 does not apply to friend declarations? For example, if I declare a class type in a header file, am I permitted to declare that class as a friend of another type in a different file?

Print this item

  Rule 15.2: MISRA warning is not generated
Posted by: vastrad - 27-09-2010, 10:47 AM - Forum: 6.15 Switch Statements - Replies (6)

Hi All,

The Rule 15.2 says:
"An unconditional break statement shall terminate every non-empty switch clause"
i.e. The last statement in every switch clause shall be a break statement, or if the switch clause is a compound statement, then the last statement in the compound statement shall be a break statement.

I understand this as:
"In a switch clause, whatever be the path traversed by the code, there shall be one break statement at the end of every path"

In a project I have the following code for which I am not getting any MISRA warning (for case 1). If my understanding is incorrect, then somebody please correct me.

Code:
switch (variable_1)
{
  case 0:
    {
        // some code here;
        break;
    }
  case 1:
    {
        // some code here;
        if (variable_2 == 0)
        {
            break;
        }
    }
    default:
        break;
}

Best Regards,
Vinay Vastrad

Print this item

  Rule 12.5: OR sequence without parentheses not compliant?
Posted by: pkrebs - 17-09-2010, 07:51 AM - Forum: 6.12 Expressions - Replies (4)

Hello,

I have a question regarding Rule 12.5: "The operands of a logical && or || shall be primary-expressions."

I often use constructs of the form "(condition1) || (condition2) || ... || (condition n)" to test for illegal values of a set of input parameters in functions (see example below), which should be compliant as far as I understand the rule text without the need of extra parentheses to group the conditions (parenthesised expression, sequence of only logical ||). However, my analysis tool (flexelint, v9.00e) complains about this construct ("non-primary expression"). Did I got something wrong about the definition of "primary expression" or is this a false positive?

Thanks in advance for any answers.

Example:

Code:
if ((start >= end) || (start > 7U) || (end > 8U))      /* raises rule violation */
{
    /* do something */
}
else
{
    /* do something different*/
}


if ((start >= end) || ((start > 7U) || (end > 8U)))      /* does not raise violation, note extra parentheses around second and third condition */
{
    /* do something */
}
else
{
    /* do something different*/
}

Print this item

  Violation for rule 109
Posted by: klaus83 - 07-09-2010, 02:57 PM - Forum: 6.18 Structures and Unions - Replies (3)

Hello everybody,

Does anybody know if rule 109: "Overlapping storage shall not be used" is violated by having two pointer variables pointing on the same address??
My automated MISRA checker only looks for union declarations and definitions when checking this rule.


Thanks,
Klaus

Print this item

  12.7 and narrowing signed integers
Posted by: tjotjos - 31-08-2010, 09:19 PM - Forum: 6.12 Expressions - Replies (2)

I have a question concerning Rule 12.7: Bitwise operators shall not be applied to operands whose underlying type is signed.

I need to transmit a 7-bit signed integer (values are restricted -64 - +63). My current method, shown below, seems to be inconsistent with 12.7.

Code:
int_8 s8a;
uint_8 u8b;
...
u8b = s8a & 0x7F;

Is the following an acceptable solution, or a violation of 10.1? Do I need to use a deviation here for the 7-bit integer?
Code:
int_8 s8a;
uint_8 u8b;
...
u8b = ((uint_8)s8a & 0x7F;

Thank you for your help!

Print this item

  Simulink window appearence
Posted by: ggentile - 30-08-2010, 04:18 PM - Forum: MISRA AC SLSF discussions - Replies (1)

Regarding rule SLSF-19. In our expirience forcing 100% zoom factor push the designer to increment the nesting level of subsystem.
We tought that the main driver is the capability to have a readable model in one window instead of 100% zoom factor.

May you provide us comment/expirience on this rule ? Or a different interpretation of the rule probably I'm wrong.

Giacomo

Print this item

  Example for 12.06 violates 2.3
Posted by: grafitemis - 23-08-2010, 04:36 PM - Forum: MISRA-C:2004 Exemplar Suite - Replies (3)

It seems that the comments in mc2_12.06.c violate Rule 2.3:
if ( mc2_1206_boolean_a & mc2_1206_boolean_b ) /* Not Compliant -
/* bitwise operation on boolean operands */
{
;
}

Regards,

Andreas

Print this item

  Rule 2.1
Posted by: Josef.Rieger - 19-08-2010, 08:15 AM - Forum: MISRA AC TL discussions - Replies (1)

Hello.
I am implementing an automated MISRA checker (MINT) and need some details regarding this rule.
Second part of rule 2.1 says "Furthermore, the signal name should be unique and not conflict with any other signal in the TargetLink model".
I am able to check this (only non-propagated labels included), however: what about library blocks? If a library block with at least one labelled line is used multiple times, then we have multiple signal lines labelled by the same label within the model.
I have also question: what is "TargetLink" model? Is it a Simulink model containing at least one TargetLink subsystem? Or is it the contents of TargetLink subsystem(s), no matter what is outside?
I would highly appreciate any comments.
Best regards,
Josef

Print this item

  Rule #3-2-3 and Forward Declarations?
Posted by: gs - 18-08-2010, 07:05 PM - Forum: 6.3 Basic concepts (C++) - Replies (4)

Does rule #3-2-3 prohibit the use of forward declarations in separate files? For example, if a file, a.h, contained "class B;" and another file, c.h, #include'd a.h and contained a definition for class D which contained "friend class B;", would the rule permit such?

Print this item

  Generalized Question about #12.6 and Preprocessor Directives
Posted by: gs - 17-08-2010, 05:39 PM - Forum: 6.12 Expressions - Replies (1)

Was advisory #12.6 intended to apply to preprocessor directives at all? I only ask because the text does not specify one way or the other.

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 322 online users.
» 0 Member(s) | 320 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: 35
Rule 0.1.2
Forum: 4.0 Language independent issues
Last Post: stephanmuench
21-11-2024, 01:12 PM
» Replies: 0
» Views: 44
A18-9-4
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
23-10-2024, 12:04 PM
» Replies: 2
» Views: 393
A8-4-5: are partial moves...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
22-10-2024, 02:03 PM
» Replies: 1
» Views: 336
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,875
MISRA AC EC guidelines
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:21 AM
» Replies: 4
» Views: 15,521
News on future releases
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:05 AM
» Replies: 1
» Views: 5,706
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: 447