<div dir="ltr">-Wpedantic in clang ToT fires on this too.<br><br>I believe the idiomatic way to do this is:<br><br>  reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(func_ptr));</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 10, 2017 at 1:27 PM Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sat, Jul 8, 2017 at 11:32 AM Dan Liew <<a href="mailto:dan@su-root.co.uk" target="_blank">dan@su-root.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 8 July 2017 at 01:40, Eric Christopher <<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>> wrote:<br>
> Hi Dan,<br>
><br>
> So this is causing warnings and breaking Werror builds:<br>
><br>
> /usr/local/google/home/echristo/sources/llvm/lib/Fuzzer/FuzzerExtFunctions.def:29:10:<br>
> warning: ISO C++ forbids casting between pointer-to-function and<br>
> pointer-to-object [-Wpedantic]<br>
>  EXT_FUNC(__lsan_enable, void, (), false);<br>
>           ^<br>
> /usr/local/google/home/echristo/sources/llvm/lib/Fuzzer/FuzzerExtFunctionsWeak.cpp:44:24:<br>
> note: in definition of macro ‘EXT_FUNC’<br>
>    CheckFnPtr((void *)::NAME, #NAME, WARN);<br>
>                         ^<br>
><br>
> Feel like fixing? :)<br>
<br>
Is this GCC or Clang and which version is this with?<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>Possibly gcc? And if so, quite old. :) I haven't tested with anything newer.</div></div></div><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I can think of two options to fix this.<br>
<br>
1. Use pragmas to disable warnings in the region. E.g.<br>
<br>
```<br>
#pragma GCC diagnostic push<br>
#pragma GCC diagnostic ignored "-Wpedantic"<br>
<br>
// do stuff<br>
<br>
#pragma GCC diagnostic pop<br>
```<br>
<br>
2. Make `CheckFnPtr a templated function so that the cast is no longer<br>
necessary.<br>
<br>
i.e. something like.<br>
```<br>
template <typename T><br>
static void CheckFnPtr(T FnPtr, const char *FnName, bool WarnIfMissing) {<br>
  if (FnPtr == nullptr && WarnIfMissing) {<br>
    Printf("WARNING: Failed to find function \"%s\".\n", FnName);<br>
  }<br>
}<br>
```<br>
<br>
I kind of prefer option 2 but I don't like the fact this will cause us<br>
to emit a different implementation of `CheckFnPtr` for every single<br>
function signature, just so we can avoid<br>
a pedantic warning.<br>
<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>It seems like a good warning?</div></div></div><div dir="ltr"><div class="gmail_quote"><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
@kcc: Any thoughts on this? Do you have any preferences for option 1<br>
or 2 or do you have an idea for a third option?<br><br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>I have no preferences, but would appreciate you fixing it if possible.</div><div><br></div><div>Thanks</div></div></div><div dir="ltr"><div class="gmail_quote"><div><br></div><div>-eric </div></div></div></blockquote></div>