Build fix: POD static_assert check fails on lttng_event_exclusions
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 21 Mar 2023 15:15:19 +0000 (11:15 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 21 Mar 2023 21:50:22 +0000 (17:50 -0400)
commit40ebe2193c00a3b67294ad38b47537cdd68b0e82
treeb6e528f26e4783b56b14cde92bc2da4fb91d2ce0
parent45cc2527c1b679884570130eca8f285b2a9a8406
Build fix: POD static_assert check fails on lttng_event_exclusions

A build error occurs when building using g++ 6.4.0 on PPC32:

  In file included from ../../src/common/buffer-view.hpp:11:0,
                   from event.cpp:9:
  ../../src/common/macros.hpp: In instantiation of 'AllocatedType* zmalloc(size_t) [with AllocatedType = lttng_event_exclusion; size_t = unsigned int]':
  event.cpp:270:77:   required from here
  ../../src/common/macros.hpp:102:2: error: static assertion failed: type can be malloc'ed
    static_assert(can_malloc<AllocatedType>::value, "type can be malloc'ed");
    ^~~~~~~~~~~~~

A bug affecting gcc [6.1, 7.4] causes flexible array members to generate
a destructor for compound types. In turn, this makes any type that
contains a flexible array a non-POD object which is a problem under some
use-case (e.g., being allocated using C-style memory management
facilities).

Explicitly specifying a length of zero works around this bug, see:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70932
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71147

The same bug affects re2 and they have fixed it in a similar way:
https://github.com/google/re2/blob/9049cd28d7496e05e7b7beaec89291d8bc6a31ee/re2/dfa.cc#L123

Change-Id: I730cdeb86bb39cdbfdc5165f854ab5906aeb2192
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
src/common/Makefile.am
src/common/compiler.hpp [new file with mode: 0644]
src/common/filter/filter-parser.ypp
src/common/lttng-kernel.hpp
src/common/sessiond-comm/agent.hpp
src/common/sessiond-comm/relayd.hpp
src/common/sessiond-comm/sessiond-comm.hpp
src/lib/lttng-ctl/lttng-ctl-health.cpp
This page took 0.025719 seconds and 4 git commands to generate.