From: Keith.S.Thompson+u@gmail.com   
      
   Kaz Kylheku <046-301-5902@kylheku.com> writes:   
   > On 2026-01-03, David Brown wrote:   
   [...]   
   >> Kaz mentioned several types that "void *" is a generic /object/ pointer.   
   >> Functions are not objects - pointers to functions are completely   
   >> different from pointers to objects. You can't mix them without "I know   
   >> what I am doing" explicit casts, with non-portable behaviour and a   
   >> serious risk of UB.   
   >   
   > "I know that I'm on POSIX" goes a long way also.   
      
   Sort of.   
      
   POSIX doesn't guarantee that all function pointers can be converted   
   to void* without loss of information. It makes that guarantee only   
   for pointers returned by dlsym().   
      
   https://pubs.opengroup.org/onlinepubs/9799919799/functions/dlsym.html   
      
   On the other hand, I'd be surprised if there were any   
   POSIX-conforming implementation that don't make that guarantee for   
   all function pointers. There are some tricks that could be played   
   to satisfy the dlsym() requirement even if function pointers are   
   bigger than void*, but I've never heard of an implementation that   
   did anything like that.   
      
   (For example, say the system has 64-bit function pointers and   
   32-bit void*. The implementation could arrange for every function   
   referenced by dlsym() to have an address with its upper 32 bits set   
   to zero, perhaps by using small wrapper functions. Other functions   
   might have arbitrary addresses so converting them to void* would   
   lose information.)   
      
   --   
   Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com   
   void Void(void) { Void(); } /* The recursive call of the void */   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|