[MacPorts] #68333: libfido2 @1.13.0: error: use of undeclared identifier 'id' (was: libfido2 fails to build with clang on 10.11 and earlier: error: use of undeclared identifier 'id')

MacPorts noreply at macports.org
Tue Oct 3 04:29:51 UTC 2023


#68333: libfido2 @1.13.0: error: use of undeclared identifier 'id'
-------------------------+-------------------------------------------------
  Reporter:              |      Owner:  trodemaster
  barracuda156           |
      Type:  defect      |     Status:  assigned
  Priority:  Normal      |  Milestone:
 Component:  ports       |    Version:  2.8.1
Resolution:              |   Keywords:  snowleopard lion mountainlion
      Port:  libfido2    |  mavericks yosemite elcapitan
-------------------------+-------------------------------------------------
Changes (by ryandesign):

 * keywords:   => snowleopard lion mountainlion mavericks yosemite elcapitan


Comment:

 Replying to [ticket:68333 barracuda156]:
 > {{{
 >
 /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_security_libfido2/libfido2/work/libfido2-1.13.0/src/hid_osx.c:189:59:
 error: use of undeclared identifier 'id'
 >         if (asprintf(&path, "%s%llu", IOREG, (unsigned long long)id) ==
 -1) {
 >                                                                  ^
 > }}}

 Weird. `id` is declared on line 173:

 {{{#!c
         uint64_t         id;
 }}}

 And it is used on line 181 apparently without complaint:

 {{{#!c
         if (IORegistryEntryGetRegistryEntryID(s, &id) != KERN_SUCCESS) {
 }}}

 Why then would it think on line 189 that it's undeclared?

 {{{#!c
         if (asprintf(&path, "%s%llu", IOREG, (unsigned long long)id) ==
 -1) {
 }}}

 > {{{
 >
 /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_security_libfido2/libfido2/work/libfido2-1.13.0/src/hid_osx.c:195:10:
 error: address of stack memory associated with local variable 'path'
 returned [-Werror,-Wreturn-stack-address]
 >         return (path);
 >                 ^~~~
 > }}}

 That doesn't seem accurate either. `path` is a pointer to a string:

 {{{#!c
         char            *path;
 }}}

 Memory is allocated on the heap (not the stack) by calling `asprintf` and
 assigned to that pointer:

 {{{#!c
         if (asprintf(&path, "%s%llu", IOREG, (unsigned long long)id) ==
 -1) {
 }}}

 It is not returning the address of stack memory. It is returning the
 address of the allocated heap memory:

 {{{#!c
         return (path);
 }}}

 Since it builds fine on macOS 10.12 (clang 900) and later and is failing
 on OS X 10.11 (clang 800) and earlier, maybe earlier clangs had some bug
 that's being exposed here. Try using a newer MacPorts clang compiler. If
 that works, maybe we'll just have to blacklist Apple clang < 900.

 You said in comment:ticket:64833:5 that you got it to compile on PowerPC
 but that you had to comment out some functions in this file, but you
 didn't mention which functions. Was it these same functions?

-- 
Ticket URL: <https://trac.macports.org/ticket/68333#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list