Opened 2 years ago

Closed 2 years ago

#27465 closed defect (fixed)

Windows: cast between incompatible function types in address.c

Reported by: teor Owned by: teor
Priority: Medium Milestone: Tor: 0.3.4.x-final
Component: Core Tor/Tor Version: Tor:
Severity: Normal Keywords: 034-must, 034-backport, 033-backport, 032-backport, 029-backport
Cc: mikeperry Actual Points:
Parent ID: #27389 Points:
Reviewer: Sponsor:


bash.exe : ../src/common/address.c: In function 'get_interface_addresses_win32':
At line:2 char:5
+     & $commandPath $args 2>&1
+     ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (../src/common/a...dresses_win32'::String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
../src/common/address.c:1499:14: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'ULONG (*)(ULONG,  ULONG,  void *, IP_ADAPTER_ADDRESSES_XP *, ULONG *)' {aka 'long unsigned int 
(*)(long unsigned int,  long unsigned int,  void *, struct _IP_ADAPTER_ADDRESSES_XP *, long unsigned int *)'} [-Werror=cast-function-type]
   if (!(fn = (GetAdaptersAddresses_fn_t)

Child Tickets

Change History (7)

comment:1 Changed 2 years ago by teor

Status: assignedneeds_information

This has bitten a lot of other projects. They used a void function pointer cast to silence the error:

In this particular case, we already got rid of the cast in 0.3.5. So we could backport that patch instead of adding another cast. (GetAdaptersAddresses and GetProcAddress are only supported on Windows XP, so our code won't work on earlier versions anyway.)

comment:2 Changed 2 years ago by teor

We could backport this commit, but we'd have to backport to 0.2.9 and later:

comment:3 Changed 2 years ago by nickm

We talked about this on #tor-dev -- casting through void(*)() is probably the answer.

comment:4 Changed 2 years ago by teor

Status: needs_informationneeds_revision

My address-cast branch has this fix, but no changes file.

comment:5 Changed 2 years ago by teor

Keywords: 033-backport 032-backport 029-backport added; 035-must removed
Status: needs_revisionneeds_review
Version: Tor:

Please see my branch bug27465-029 on

We already fixed this issue in 0.3.5 by removing the lookup and cast in #26481. So the code will conflict when merging to 0.3.5, we should do an --ours merge (and delete the changes file?).

comment:7 Changed 2 years ago by nickm

Resolution: fixed
Status: needs_reviewclosed

Merged to 0.2.9 and forward; the 0.3.5 merge was a no-op as noted above.

Note: See TracTickets for help on using tickets.