Rule 5-2-6 and dynamicaly loading (.dll / .so)

Moderators: david ward, misra cpp

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

Rule 5-2-6 and dynamicaly loading (.dll / .so)

Postby udi » Tue Dec 18, 2018 8:42 am

The rule forbids conversion between function pointer types.
I believe that this rule should exempt a function retrieved with GetProcAddress / dlsym, as I believe this is not an undefined / unspecified behavior (or is it?).
It might make sense to add a requirement to review and document these cases.

dg1980
Posts: 108
Joined: Wed Apr 27, 2016 2:33 pm
Company: Elektrobit Automotive GmbH

Re: Rule 5-2-6 and dynamicaly loading (.dll / .so)

Postby dg1980 » Tue Dec 18, 2018 12:07 pm


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

Re: Rule 5-2-6 and dynamicaly loading (.dll / .so)

Postby udi » Tue Dec 18, 2018 12:30 pm


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

Re: Rule 5-2-6 and dynamicaly loading (.dll / .so)

Postby misra cpp » Wed Jan 30, 2019 10:22 am

You are correct, 5-2-6 bans all casts to/from function pointer types.

MISRA C++ only considers the language as defined by the C++ standard. GetProcAddress and dlsym are from operating system specific libraries (Windows and Linux), so any special treatment of them is outside the scope of this document.

However, their use can be addressed by raising a deviation. For further guidance, see the MISRA Compliance document – in effect the review and document solution you propose.
Posted by and on behalf of
the MISRA C++ Working Group


Return to “6.5 Expressions (C++)”

Who is online

Users browsing this forum: No registered users and 1 guest