5-0-4 false positive?

Moderators: david ward, misra cpp

Post Reply
Posts: 109
Joined: Wed Apr 27, 2016 2:33 pm
Company: Elektrobit Automotive GmbH

5-0-4 false positive?

Post by dg1980 » Wed Sep 06, 2017 8:50 am

Dear MISRA team,

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

Code: Select all

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.

misra cpp
Posts: 151
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

Re: 5-0-4 false positive?

Post by misra cpp » Fri Sep 22, 2017 4:24 pm

This is not one of our examples. If you are saying that your static analysis tool reports this as an error, you need to contact your tool vendor
The sign-ness of the underlying types haven't changed

You're right, we need a reference for the implementation defined behaviour
Posted by and on behalf of
the MISRA C++ Working Group

Post Reply

Return to “6.5 Expressions (C++)”