MISRA Discussion Forums
Rule 0-1-7 Exception clarification - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18)
+--- Forum: MISRA C++:2008 rules (https://forum.misra.org.uk/forumdisplay.php?fid=19)
+---- Forum: 6.0 Language independent issues (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=129)
+---- Thread: Rule 0-1-7 Exception clarification (/showthread.php?tid=1504)



Rule 0-1-7 Exception clarification - udi - 01-09-2019

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 ?


Re: Rule 0-1-7 Exception clarification - misra cpp - 16-10-2019

(void) is the only one allowed by the wording of this rule, and this is intentional so its easy to spot