Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 11.1, 11.2 (and others?) vs conversion caused by equality operators (and similar)?
#1
Hello,

rules 11.1 and 11.2 disallow conversions between pointer to a function or incomplete type, and any other type:

Code:
void (*fp1)(short);
void (*fp2)(int);

fp2 = fp1;          /* Not-compliant - different function */
fp2 = 0x8000;       /* Not-compliant - integer */

What if the conversion happens for example in equality operator:
Code:
fp2 == fp1;         /* Compliant or Not-compliant ? */
fp2 != 0x8000;      /* Compliant or Not-compliant ? */

Following example from Rule 11.1 suggests it's also non-compliant:
Code:
if ( fp2 != NULL )  /* Compliant - exception 1 (NULL) */


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)