Return to Home
  View the contents of your Cart View cart  
  0 item(s) in cart  
  Checkout  

Gimpel Software - Discussion Forum
Discussion Forum
We invite you to use this forum to communicate with other PC-lint and FlexeLint users. You do not need to log in to post a message. WARNING: Your email address will not be encrypted. We recommend that you obfuscate it as protection from web crawlers. To receive technical support directly from Gimpel Software, please follow the guidelines at http://www.gimpel.com/html/support.htm
Gimpel Software - Discussion Forum
Subject From Date & Time
Info 747: Significant prototype coercion int to bool AOZ July 02, 2018
5:18:09 AM
  Re: Info 747: Significant prototype coercion int to bool July 02, 2018
1:29:19 PM
          Re: Info 747: Significant prototype coercion int to bool July 03, 2018
1:31:24 AM
 
Subject: Info 747: Significant prototype coercion int to bool
Date: July 02, 2018
5:18:09 AM
Name: AOZ
Email: nospam@nospam.com
Message:
#include <stdint.h>
/*lint -A(C99) -w3 -indirect(au-misra3.lnt
-esym(970,_Bool)) */

static volatile uint8_t flags;

void func(const _Bool b);
void func(const _Bool b){
  if (b) {
    ;
  } else {
    /* do nothing */
  }
}

void main(void);
void main(void){
  const uint8_t mask = 0x44U;
  func((flags & mask) == 0U); 
  /***************************************
   * boolean by context 
   * essentially boolean expression
   * but 
   * Info 747:  Significant prototype coercion 
   * (arg. no. 1) int to bool 
   **************************************/
}

Is this intended?
Reply to this Message! Previous Message Next Message
 
Subject: Re: Info 747: Significant prototype coercion int to bool
Date: July 02, 2018
1:29:19 PM
Message:
First, this message is not flagged with a MISRA Rule number, 
so you can always turn it off.  
Secondly, because PC-Lint is much older than MISRA, it does 
some more checks. 
Technically, the message is correct, because essentially 
boolean is a MISRA invention, while internally the expression 
still has type int - even in C99 (i think i read a paragraph about 
it in the official MISRA document). 
Reply to this Message! Previous Message Next Message
 
Subject: Re: Info 747: Significant prototype coercion int to bool
Date: July 03, 2018
1:31:24 AM
Message:
Here is the relevant paragraph from MISRA C 2012 
Appendix D:

Logical expressions A boolean type does not exist 
in the C90 language. Type _Bool was introduced 
into C99, but unfortunately, for reasons of 
backwards compatibility, the result of equality 
(==, !=), relational (<, <=, >=, >), and logical 
(&&, ||, !) operators is still of type int rather 
than type _Bool
Reply to this Message! Previous Message Next Message