Clarification for Rule 5-2-4

Moderators: david ward, misra cpp

Post Reply
Posts: 12
Joined: Wed Sep 06, 2017 4:25 pm
Company: Gimpel Software

Clarification for Rule 5-2-4

Post by abgs » Fri Jul 26, 2019 3:06 pm

1. Does the phrase "functional notation cast" in the rule correspond to what the C++ standard calls an "Explicit type conversion (functional notation)", or is there a distinction?

2. Does the phrase "explicit constructor call" in the rule mean "explicit-constructor call" (a call to a constructor declared with the 'explicit' specifier) or "explicit constructor-call" (an explicit call to a constructor, as opposed to an implicit conversion that uses a user-defined converting constructor)?

3. The rationale refers to dangers associated with casts that "do not invoke a converting constructor", however a "converting constructor" is a constructor that was *not* declared with the 'explicit' specifier. Was this intended to refer to casts that *do* invoke a converting constructor [as opposed to an explicit constructor]?

4. In the first compliant example with the expression 'A(10)' the declared constructor 'A(int32_t)' is declared with the explicit specifier. Would the 'A(10)' example be non-compliant if this constructor declaration lacked the 'explicit' specifier?

5. In later versions of the C++ standard, "Explicit type conversion (functional notation)" includes a type name followed by a braced list, e.g. 'X{5}', which may be used for aggregate initialization for 'struct X { int32_t a; };'. Is it within the original spirit of the rule to include this sytnax?

Post Reply

Return to “6.5 Expressions (C++)”