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

Username
  

Password
  





  5-0-4 false positive?
Posted by: dg1980 - 06-09-2017, 07:50 AM - Forum: 6.5 Expressions (C++) - Replies (1)

Dear MISRA team,

the following comparison of two values of the same type is marked as violation of 5-0-4:

Code:
typedef unsigned char ui8;

extern ui8 a;
extern ui8 b;

void test(void)
{
  if (a != b)// false positive?
  {
    a = b;
  }
}

Is this a false positive?
I fail to see implementation-defined behaviour.
BTW, the rule scope/text fails to reference the implementation-defined behaviour.
Thanks.

Print this item

  Can I get involved in MISRA?
Posted by: GerlindeKettl - 03-08-2017, 09:43 AM - Forum: General Questions - Replies (1)

The FAQ on the MISRA website https://www.misra.org.uk/FAQ/tabid/64/Default.aspx says:
We welcome active participants in our working groups who are prepared to contribute to the technical work of these groups. From time to time we ask for external reviewers to comment on drafts of our documents. Please contact us if you are interested in either of these.

MISRA Contact Details can be found here: https://www.misra.org.uk/MISRAHome/Conta...fault.aspx, but states that this is for sale of MISRA documents only and please use the Bulletin Board for all technical questions. So how can I contact MISRA if I want to get involved?

Print this item

  MISRA C:2012 TC1 now available
Posted by: david ward - 01-08-2017, 09:53 AM - Forum: Announcements - No Replies

Since the publication of MISRA C:2012 and its adoption by industry and the wider C community, a number of issues have arisen, both from discussions within the MISRA C Working Group and in response to feedback via the MISRA C Forum on this bulletin board.

MISRA C:2012 Technical Corrigendum 1 provides clarification on these issues, and should be read in conjunction with the original MISRA C:2012 document.

The document is available to download from the resources section, see https://www.misra.org.uk/forum/viewtopic...241&t=1670

Print this item

  MISRA C:2012 TC1
Posted by: david ward - 01-08-2017, 09:52 AM - Forum: MISRA resources - No Replies

MISRA C:2012 Technical Corrigendum 1 - Technical clarification of MISRA C:2012

Since the publication of MISRA C:2012 and its adoption by industry and the wider C community, a number of issues have arisen, both from discussions within the MISRA C Working Group and in response to feedback via the MISRA C Forum on this bulletin board.

This document provides clarification on these issues, and should be read in conjunction with the original MISRA C:2012 document.



Attached Files
.pdf   MISRA C 2012 TC1.pdf (Size: 135.93 KB / Downloads: 139)
Print this item

  Initialisation of arrays of floats
Posted by: sdcandy - 19-07-2017, 01:04 PM - Forum: 8.9 Initialization - Replies (1)

Rule 9.3 in MISRA C:2012 has an exception which states "An initializer of the form { 0 } may be used to explicitly initialize all elements of an array object or subobject". This means that something of the form is acceptable:

Code:
uint32_t x[3] = { 0 };

When using floating point types is it also acceptable to use something of the form:

Code:
typedef double float64_t;
float64_t array_a[10] = { 0.0 };

-Andy.

Print this item

  Rule 11-0-1 and protected members
Posted by: tw39124 - 03-07-2017, 02:42 PM - Forum: 6.11 Member access control (C++) - Replies (1)

Rule 11-0-1 says that "Member data in non-POD class types shall be private" and the example clarifies that both "public" and "protected" members violate this rule. The rationale says "the implementation retains more control over how the object state can be modified".

I fail to see how protected members diminish the "control" over the object state that the implementation has. Can someone explain in more detail why protected member variables specifically are disallowed? A subtype has an "is-a" relationship with the base type, after all, so I don't see why it shouldn't benefit from inheriting the base type's member variables.

Print this item

  Rule 3-9-2 and operator overloading
Posted by: dg1980 - 30-06-2017, 09:01 AM - Forum: 6.3 Basic concepts (C++) - Replies (3)

Dear MISRA team,

according to ISO/IEC 14882:2003 chapter 13.5.7 a single int is required to distinguish between prefix and postfix operators:

Code:
class X {
public:
X& operator++(); // prefix ++a
X operator++(int); // postfix a++
};

If you recategorize 3-9-2 as mandatory would the usage of int require a deviation or is it an explicit exception (compare with int main exception in DIR 4.6 of MISRA C 2012) ?
Thanks.

Print this item

  Rule 2.2 dead code and empty function
Posted by: xiangke - 26-06-2017, 05:59 AM - Forum: 8.2 Unused code - Replies (1)

An empty function is the dead code? for example:
/*file1.c*/
void vidNextStep(void)
{

}
/*file2.c*/
void test(void)
{
vidNextStep();
}
I think an empty function is the dead code, because it shall be called, it means that it shall execute, but It shall not affect program behavior.
Do it?

Print this item

  Rule 14.2 and system level
Posted by: xiangke - 14-06-2017, 09:13 AM - Forum: 8.14 Control statement expressions - Replies (1)

As We know, analysis of scope is classified as single translation unit and system.
Rule 14.2 is system analyzed scope,
In my opinion, a For loop is always placed on a function, it is a code block. a loop counter it uses has no linkage.why the analysis for it shall be dependent on the other module, can anybody give a example for explanation?
thanks very much in advance!

Print this item

  Valid typedef name rule for float/double data type
Posted by: Anitha Rajasekar - 13-06-2017, 07:17 AM - Forum: 7.4 Code design - Replies (1)

We are appending some prefix for the typedef name as below
typedef float UI_FLOAT_32.

It shows the warning for the above line of code as
1. misra_violation: [Advisory] MISRA C-2012 Directive 4.6 violation: typedefs that indicate size and signedness should be used in place of the basic float numerical type.

MISRA Violation
Typedefs Of Basic Types With Names That Do Not Indicate Size And Signedness
MISRA advises compliance with this rule.

The same issue is not coming if we use FLOAT32..
Is there any rule for the typedef name used for float and double.

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 111 online users.
» 0 Member(s) | 107 Guest(s)
Bing, Facebook, 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: 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: 724
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