Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clarification for Rule 5-2-4
#2
1) "functional notation cast" is what the C++ standard calls an "Explicit type conversion (functional notation)"
2) the presence or absence of the keyword “explicit” is not relevant
3) the intent is to allow function notation casts only if the destination type is a class type
4) A(10) would be compliant for this rule, but the declaration of A’s constructor would violate the rule that requires the use of “explicit” (12-1-3)
5) Our next release will consider future versions of the C++ standard, as at present the use of X{5} would violate current rule 1-0-1, but it would appear compliant with the spirit of the rule

To summarise, functional notation cast means int(32) is non-compliant. However, C(32) where C is a class with a constructor with an integer parameters is compliant, this is what was meant by 'an explicit constructor call'
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)