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

Username
  

Password
  





  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

  12.6 for Preprocessor Directives?
Posted by: gs - 05-08-2010, 01:46 PM - Forum: 6.12 Expressions - Replies (3)

Was 12.6 intended to prohibit the use of the '!' operator on such code as

Code:
#if ! defined A
#endif
?

Could a case not be made the result of 'defined' is an "effectively Boolean Expression"?

Print this item

  6.2 With Respect to Arrays and Pointers?
Posted by: gs - 29-07-2010, 03:23 PM - Forum: 6.6 Types - Replies (1)

Is the following code permitted or prohibited by rule 6.2?

Code:
signed char a[10] = {"123456789"};
signed char *b = "123456789";

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 176 online users.
» 0 Member(s) | 173 Guest(s)
Bing, 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: 427
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: 723
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: 436
M5-0-4 switch over unscop...
Forum: 6.5 Expressions (C++)
Last Post: misra cpp
25-09-2026, 01:00 PM
» Replies: 3
» Views: 537