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

Username
  

Password
  





  Essential Type of an Expression Clarification
Posted by: gs - 14-02-2014, 07:50 PM - Forum: 8.10 The essential type model - Replies (1)

Suppose I have:

Code:
((unsigned short) 1u) + ((unsigned short) 2u);
The essential type of each constant, '1u' and '2u', is unsigned char and the casts make the essential type of each operand unsigned short. Now, if shorts are 16 bits wide and chars are 8 bits wide, what is the essential type of the expression; unsigned char because of the value, '3u', or unsigned short because of the operands?

Print this item

  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

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,206
» Latest member: saad.essahli
» Forum threads: 1,017
» Forum posts: 2,796

Full Statistics

Online Users
There are currently 150 online users.
» 0 Member(s) | 146 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: 176
A3-3-2 Contradictory exam...
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
31-03-2025, 09:30 AM
» Replies: 2
» Views: 309
16.6.1 clarification
Forum: 4.16 Overloading
Last Post: cgpzs
31-03-2025, 09:29 AM
» Replies: 2
» Views: 289
Rule 9.3.1 - iteration st...
Forum: 4.9 Statements
Last Post: misra cpp
28-03-2025, 01:17 PM
» Replies: 1
» Views: 194
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: 214
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: 173
Adopted modal expressions...
Forum: General Questions
Last Post: Yordan Naydenov
17-03-2025, 09:01 AM
» Replies: 0
» Views: 271
Roadmap to c23 support
Forum: General Questions
Last Post: ACHart
28-02-2025, 03:23 PM
» Replies: 0
» Views: 219
Rule 6.2.1 weak linkage
Forum: 4.6 Basic concepts
Last Post: misra cpp
28-02-2025, 01:04 PM
» Replies: 1
» Views: 272
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: 702