jankratochvil marked 2 inline comments as done.
jankratochvil added inline comments.


================
Comment at: lldb/source/Host/common/HostInfoBase.cpp:250
+      reinterpret_cast<void *>(
+          HostInfoBase::ComputeSharedLibraryDirectory)));
 
----------------
labath wrote:
> jankratochvil wrote:
> > The source is a `static bool ComputeSharedLibraryDirectory(FileSpec 
> > &file_spec);` and destination is `void *` so there is no intermediate 
> > integer cast needed: [[ https://stackoverflow.com/a/2613393/2995591 | 
> > Casting pointer to object to void * in C++ ]]
> > It was caught by D71707 as `intptr_t` is dangerous.
> > 
> I seem to recall some compilers complaining (though still accepting) about 
> code which casts function pointers to void*, with this being the only 
> available workaround. However, I can't reproduce this now, so I guess this 
> could be fine..
I had to study it myself now as I also remembered something like that. It is 
valid complaint for plain C: https://stackoverflow.com/a/12359083/2995591
But it does not apply ("conditionally") for C++: 
https://stackoverflow.com/a/12360610/2995591
And it is valid for C++ of: clang-8.0.0-3.fc30.x86_64 && gcc-9.2.1-1.fc30.x86_64
So I would think for C++ it is OK now without the (u)intptr_ intermediate cast.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71498/new/

https://reviews.llvm.org/D71498



_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to