Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 0-1-7 Exception clarification
#1
Hi,

I have 3 questions:
1. Why in the exception for the rule, a C-style cast was used (like in case #1 below), instead of functional notation cast (like in case #2 below)?
2. Does using a functional notation cast violates this rule?
3. Is it legit to do the cast through a typedef as shown in case 3 (or 4 in case that functional notation cast is allowed for that purpose)?

Thanks,
Udi.
==== Below are the referenced code examples ===
namespace SE
{
typedef void UnusedRetVal;
}

1. (void)std::strtol(pszValue, &pszEndPtr, 10); // copmliant
2. void(std::strtol(pszValue, &pszEndPtr, 10)); // not compliant ?
3. (SE::UnusedRetVal)std::strtol(pszValue, &pszEndPtr, 10); // not compliant ?
4. SE::UnusedRetVal(std::strtol(pszValue, &pszEndPtr, 10)); // not compliant ?
<t></t>
Reply
#2
(void) is the only one allowed by the wording of this rule, and this is intentional so its easy to spot
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)