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

Username
  

Password
  





  Clarity of Rule 14-6-1
Posted by: Insane Vent Storm - 17-02-2016, 01:21 PM - Forum: 6.10 Derived classes (C++) - Replies (1)

Rule 14-6-1 says 'In a class template with a dependant base, any name that may be found in that dependant base shall be referred to using a qualified-id or this->'. Does the use of the word 'template' mean that the rule applies to template classes, or does the rule apply to all inheriting classes ?

Print this item

  10.3 Clarification on assigning unsigned literal to signed
Posted by: michael.metivier - 08-02-2016, 02:54 PM - Forum: 8.10 The essential type model - Replies (3)

Quote:A non-negative integer constant expression of essentially signed type may be assigned to an object of essentially unsigned type if its value can be represented in that type.

While Rule 10.3 has this Exception for constructions similar to
Code:
uint8_t u8a = 0;    /* By exception */
there does not seem to be a similar exception for the inverse
Code:
int8_t s8a = 1u;    /* Compliant? */
Our current analysis tool flags this as an error, but this assignment seems no more dangerous than the one given by the Example. Is there a specific rationale for why this assignment should not be allowed, given the condition of the Exception
Quote:if its value can be represented in that type.
?

Print this item

  Rule 2-10-6
Posted by: Mats Fors - 26-01-2016, 09:04 AM - Forum: 6.2 Lexical conventions (C++) - Replies (1)

Shouldn't example one be compliant?

typedef struct vector {...} vector;

The two vector identifiers are both referring to the same type.

Print this item

  Rule 16-0-1 and extern "C"
Posted by: detra - 14-01-2016, 08:45 AM - Forum: 6.16 Preprocessing directives (C++) - Replies (2)

Hello,
if we want to use the same Header files for "C" and "C++" we must use the "extern C" constuct. But the "extern C" construct must be placed before the include of the Header and so our tool reports a MISRA 16-0-1 violation. Is this violation valid? And if so, is there an other solution?

Code:
#ifndef _MYHEADER_
#define _MYHEADER_

extern "C"
{
    #include "firstheader.h"                // MISRA 16-0-1 violation
}

Thank you for help,
Stefan

Print this item

  Code generators for MISRA C++
Posted by: Insane Vent Storm - 04-01-2016, 12:55 PM - Forum: C++ General - No Replies

On the general subject of MISRA compliance and auto-code, is anyone out there using a code generating tool and trying to produce MISRA C++ 2008 compliant code ?

Print this item

  Essential type of constant expressions
Posted by: roberto - 27-12-2015, 05:06 PM - Forum: 8.10 The essential type model - Replies (1)

In MISRA-C:2012, it is stated that the essential type of the constant expression ~(unsigned short)3 is the UTLR of its value (i.e., -4), but the definition of UTLR seems not to cover this case (that is, the UTLR of -4 is undefined).

Another similar example is (unsigned char)3 - (unsigned char)4.

What is the essential type of these constant expressions?

Print this item

  15.7 and side effects
Posted by: lovewar - 11-12-2015, 12:08 AM - Forum: 8.15 Control flow - Replies (2)

Would the following examples be compliant with rule #15.7?

Code:
void R_15_7 ( void ) {
   bool_t flag_1 = get_bool ( );
   bool_t flag_2 = get_bool ( );
   if ( flag_1 )  {
      action_f1 ( );
   }
   else if ( flag_2 )  {
      action_f2 ( );
   }
   else {  // here , is the "else" compliant ?
      persistent_side_effects();
  }
}

Would the following examples be compliant with rule #15.7?
Code:
void R_15_7 ( void ) {
   bool_t flag_1 = get_bool ( );
   bool_t flag_2 = get_bool ( );
   if ( flag_1 )  {
      action_f1 ( );
   }
   else if ( flag_2 )  {
      action_f2 ( );
   }
   else {  // here , is the "else" compliant ?
      side_effects();
  }
}

Would the following examples be non-compliant with rule #15.7?
Code:
void R_15_7 ( void ) {
   bool_t flag_1 = get_bool ( );
   bool_t flag_2 = get_bool ( );
   if ( flag_1 )  {
      action_f1 ( );
   }
   else if ( flag_2 )  {
      action_f2 ( );
   }
   else {  // here, is the "else" non-compliant ?
      no_side_effects();
  }
}

Print this item

  Rule 19.1 and assigment between members of a struct
Posted by: GerlindeKettl - 20-11-2015, 10:34 AM - Forum: 8.19 Overlapping storage - Replies (1)

Does this code violate rule 19.1?

Code:
struct s_tag {  
uint8 ReadPos;
uint8 WritePos; };
typedef struct s_tag s;

union u_tag {
s      Elements;
uint32 Value; };
typedef union u_tag u;

u NewState;
NewState.Elements.ReadPos  = NewState.Elements.WritePos;
My static code checker thinks it is a violation, but from my point of view I'm just assigning one member of a struct to a different member of the struct and they don't overlap in memory. That this struct is a member of a union should not matter as there is no assignment across the members of the union.

Print this item

  MISRA C 2012 rule 8.6
Posted by: mcorles5 - 18-11-2015, 02:00 PM - Forum: General Questions - Replies (1)

The rule definition is "An identifier with external linkage shall have exactly one external definition." When I look at where it says there are multiple definitions, it points to the same line.
Ie.
global variable 'CALIBRATION_MISMATCH' has multiple tentatives of definitions (C:\User\Desktop\globals.c:137, C:\Users\Desktop\globals.c:137) (Required)
U8 CALIBRATION_MISMATCH;

Print this item

  Making constants in MISRA compliant C++
Posted by: Insane Vent Storm - 09-11-2015, 01:52 PM - Forum: 6.1 General (C++) - Replies (8)

I am trying to declare a constant for use in fixing the size of several C++ arrays. I have tried 3 options:
1) #'define MaxTracksConst 8

2) const Rhp_int32_t MaxTracksConst(8);

3) enum %s {one, two, three, four, five, six, seven, MaxTracksConst}

but our LDRA MISRA checker finds fault with all of them ( 1. fails 16-2-2, 2. fails 3-1-1 and 3. fails 4-5-2 ).
Am I missing something, or is there an option that will pass MISRA C++ 2008 checks ?

Kind regards
Insane Vent Storm

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,207
» Latest member: MLBstubs
» Forum threads: 1,017
» Forum posts: 2,796

Full Statistics

Online Users
There are currently 209 online users.
» 0 Member(s) | 205 Guest(s)
Bing, Google, UptimeRobot, Yandex

Latest Threads
Rule 7.0.5, example non-c...
Forum: 4.7 Standard conversions
Last Post: cgpzs
17-04-2025, 12:10 PM
» Replies: 0
» Views: 169
A3-3-2 Contradictory exam...
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
31-03-2025, 09:30 AM
» Replies: 2
» Views: 297
16.6.1 clarification
Forum: 4.16 Overloading
Last Post: cgpzs
31-03-2025, 09:29 AM
» Replies: 2
» Views: 279
Rule 9.3.1 - iteration st...
Forum: 4.9 Statements
Last Post: misra cpp
28-03-2025, 01:17 PM
» Replies: 1
» Views: 187
Rule 8.2.8 - why aren't a...
Forum: 4.8 Expressions
Last Post: misra cpp
28-03-2025, 01:05 PM
» Replies: 1
» Views: 208
Typo in Appendix C of MIS...
Forum: 8.10 The essential type model
Last Post: Yordan Naydenov
17-03-2025, 02:58 PM
» Replies: 0
» Views: 164
Adopted modal expressions...
Forum: General Questions
Last Post: Yordan Naydenov
17-03-2025, 09:01 AM
» Replies: 0
» Views: 262
Roadmap to c23 support
Forum: General Questions
Last Post: ACHart
28-02-2025, 03:23 PM
» Replies: 0
» Views: 211
Rule 6.2.1 weak linkage
Forum: 4.6 Basic concepts
Last Post: misra cpp
28-02-2025, 01:04 PM
» Replies: 1
» Views: 267
A8-4-5: Should have an ex...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
21-02-2025, 12:58 PM
» Replies: 3
» Views: 695