gcc 11.x fixes 96/26496/2 12.90.1 12.91.0 12.92.0 12.93.0 13.93.0 marlin/12.90.1 marlin/12.91.0 marlin/12.92.0 marlin/12.93.0 marlin_12.90.1 marlin_12.91.0 marlin_12.92.0 marlin_12.93.0 needlefish/13.93.0 needlefish_13.93.0
authorScott Murray <scott.murray@konsulko.com>
Mon, 12 Jul 2021 19:51:18 +0000 (15:51 -0400)
committerScott Murray <scott.murray@konsulko.com>
Mon, 12 Jul 2021 20:48:08 +0000 (20:48 +0000)
Changes for compiling with gcc 11.x:
- g++ now seems to instantiate duplicate entries for the set member
  function in the contextclass template class in binding-wrap.hpp.
  The use of a closure as a default argument value seems to be the
  culprit, as it seems there are longstanding issues with respect to
  using closures like that and resulting symbol names (i.e. the use
  of a closure isn't necessarily recognized as generating unique
  instantiations).  In theory, C++17 should explicitly allow this
  when the closure has no captures, but bumping up to -std=gnu++17
  did not fix the issue.  To avoid it, replace the closure usage
  with a private static member function.
- In afb-hook.c, tweaked the ignoring of the writev return code to
  make the stricter checking in gcc 11 happy.
- In decode_base64 in wrap-json.c, initialize u16 as gcc now seems
  to miss that it will be initialized on the first loop iteration.

Bug-AGL: SPEC-3819

Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: I8876db196b46cc35ecd2798e20d5ec3425df865e

include/afb/c++/binding-wrap.hpp
src/afb-hook.c
src/wrap-json.c

index f94d1bc..b798cf1 100644 (file)
@@ -300,6 +300,7 @@ public:
                friend class req;
                afb_req_t req_;
                contextclass(afb_req_t r) : req_(r) {}
+               static void default_destroyer(T*t) { delete t; }
 
        public:
                inline operator T *() const { return get(); }
@@ -312,7 +313,7 @@ public:
                                        nullptr));
                }
 
-               inline void set(T *value, void (*destroyer)(T*) = [](T*t){delete t;}) const {
+               inline void set(T *value, void (*destroyer)(T*) = default_destroyer) const {
                        afb_req_context(req_, 1,
                                nullptr,
                                reinterpret_cast<void(*)(void*)>(destroyer),
index d2ea0b6..9bd480b 100644 (file)
@@ -201,7 +201,7 @@ static void _hook_(const char *fmt1, const char *fmt2, va_list arg2, ...)
        iov[4].iov_base = (void*)&chars[9];
        iov[4].iov_len = 1;
 
-       (void)writev(2, iov, 5);
+       (void)!writev(2, iov, 5);
 
        free(mem1);
        free(mem2);
index 6fce73b..3a76482 100644 (file)
@@ -200,7 +200,7 @@ static int decode_base64(
                size_t *decodedlen,
                int url)
 {
-       uint16_t u16;
+       uint16_t u16 = 0;
        uint8_t u8, *result;
        size_t in, out, iin;
        char c;