Rule 0-1-7 Exception clarification

Moderators: david ward, misra cpp

Post Reply
udi
Posts: 9
Joined: Wed May 11, 2016 8:24 am
Company: Elbit

Rule 0-1-7 Exception clarification

Post by udi » Sun Sep 01, 2019 2:36 pm

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 ?

misra cpp
Posts: 148
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

Re: Rule 0-1-7 Exception clarification

Post by misra cpp » Wed Oct 16, 2019 11:55 am

(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

Post Reply

Return to “6.0 Language independent issues (C++)”