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

Username
  

Password
  





  Rule 4-10-2 NULL is not a c++ standard
Posted by: minhyuk - 07-02-2014, 07:34 AM - Forum: 6.4 Standard conversions (C++) - Replies (4)

In C++ Standard, There are not exist NULL(its C standard).
So, Programmer should to know about this and Use constant 0 instead of NULL macro.

Print this item

  Rule 10.1 violation with casting
Posted by: Frasew - 06-02-2014, 12:29 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (1)

Hello,

my MISRA checker generates a MISRA violation 10.1 (The signedness of an integer type is converted implicitly.(signed -> unsigned)), although a casting is done.

My C code:

1: #include
2: typedef unsigned char U8;
...
w: U8 WriteProtect = (U8) true;
....
x: if(WriteProtect == (U8) false) {
....
y: WriteProtect = (U8) true;
....
z: }

The MISRA checker identifies line x and y as a rule 10.1 violation. Why is this a rule 10.1 violation although a casting is done? Interestingly the MISRA checker identifies line w as OK. Have anybody an idea what is my fault?

Is it generally impossible in MISRA to assign a signed var to an unsigned var?

Print this item

  Rule 11.3
Posted by: schileboh - 31-01-2014, 09:47 AM - Forum: 8.11 Pointer type conversions - Replies (1)

hello guys

i've a problem. i'm not sure if the following code is compliant to the Rule 11.3:

Code:
typedef struct SomeHeaderType
{
   uint8_t type;
   uint32_t timestamp;
   uint16_t some_attribute;
}SomeHeaderType;

void foo(uint8_t *buffer_ptr)
{
   SomeHeaderType *headerPtr = (SomeHeaderType*)buffer_ptr;
   if(headerPtr->type == 3)
   {
      uint16_t attribute = headerPtr->some_attribute;
      ...
   }
   ...
}

is it allowed to cast a 8-bit buffer pointer to a struct pointer? from my point of view, this code is not compliant, but i have some code examples here that do this and the code suggests to be MISRA conform...

thanks for clarification.

Print this item

  2.4 violation?
Posted by: gs - 28-01-2014, 05:54 PM - Forum: 7.2 Compilation and build - Replies (1)

Does the following example violate rule #2.4:

Code:
typedef enum A {
    b
} A;

A c() {
    return b;
}

Print this item

  Rule 19.1 Example
Posted by: minoru.kanome - 22-01-2014, 07:33 AM - Forum: 8.19 Overlapping storage - Replies (3)

rule 19.1 example :

a = b; /* Compliant - exception 1 */

a and b are not overlapping object.
Therefore, this code is improper as the example.
Is it right?

Print this item

  Rule 15.3 Example
Posted by: ogawa.kiyoshi - 21-01-2014, 10:09 AM - Forum: 8.15 Control flow - Replies (1)

Rule 15.3 Example
void f1(int32_t a){
if ( a 0){
L2:
;
}
}
has some unreachable codes. So I think
void f1(int32_t a){
if ( a 0){
L2:
;
}
}
are enough and no unreachable codes.

Dr. Ogawa Kiyoshi
https://twitter.com/kaizen_nagoya/, http://researchmap.jp/kaizen/MISRA-C/

Print this item

  Rule 13.2 Example
Posted by: ogawa.kiyoshi - 21-01-2014, 02:32 AM - Forum: 8.13 Side effects - Replies (1)

In Rule 13.2 Example

#define COPY_ELEMENT ( index ) ( a[( index )] = b[( index )] )

The print may have a space between COPY_ELEMENT and '('.
It generate
( index ) ( a[( index )] = b[( index )] ) ( i++ );

#define COPY_ELEMENT( index ) ( a[( index )] = b[( index )] )
"no space" seem proper.

Dr. Ogawa Kiyoshi
@kaizen_nagoya, http://researchmap.jp/kaizen/MISRA-C/

Print this item

  Constant Size and Rule 12.2
Posted by: mjlinden - 20-01-2014, 02:33 PM - Forum: 8.7 Literals and constants - Replies (4)

Hi Folks,

I'm trying to come to an understanding of an issue associated with MISRA 2012 Rule 12.2 and the interpretation of constant size. Here is the situation I'm dealing with.

=====================================================================
int32_t result;

result = (1

Print this item

  Rule 10-3-1
Posted by: wcarl - 17-01-2014, 04:48 PM - Forum: 6.10 Derived classes (C++) - Replies (3)

There shall be no more than one definition of each virtual function on each path through the inheritance hierarchy.

If I'm interpreting this rule correctly, once you define a virtual function for a derived class with the virtual base class as an ancestor, no more derivations in the chain can override the first definition.

This would seem to cripple a key advantage of using classes and an object-oriented design.

Isn't it pretty common to override a virtual member function in a child class even if the parent class has provided a different definition? Please explain.

Print this item

  Rule 6.1
Posted by: Akhil - 15-01-2014, 06:48 AM - Forum: 8.6 Types - Replies (1)

In the Amplification for Rule 6.1 :

For C99 : The appropriate types are :

1. either unsigned or signed int.
This refers to unsigned int and signed int only OR any other datatype..?

2. Another explicitly signed or explicitly unsigned integer type that is premitted by the implementation.
What all types does this refer to ? Does this refer to unsigned short OR unsigned short int etc.

Please clarify.

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 121 online users.
» 0 Member(s) | 117 Guest(s)
Bing, DuckDuckGo, 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: 625
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: 428
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: 598
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: 727
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: 437
M5-0-4 switch over unscop...
Forum: 6.5 Expressions (C++)
Last Post: misra cpp
25-09-2026, 01:00 PM
» Replies: 3
» Views: 539