Commit | Line | Data |
---|---|---|
40ebe219 JG |
1 | /* |
2 | * Copyright (C) 2023 Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
3 | * | |
4 | * SPDX-License-Identifier: LGPL-2.1-only | |
5 | * | |
6 | */ | |
7 | ||
8 | #ifndef LTTNG_COMPILER_HPP | |
9 | #define LTTNG_COMPILER_HPP | |
10 | ||
11 | /* | |
12 | * A bug in gcc [6.1, 7.4] causes flexible array members to generate a destructor | |
13 | * for compound types. In turn, this makes any type that contains a flexible array | |
14 | * a non-POD object which is a problem under some use-case (e.g., being allocated | |
15 | * using C-style memory management facilities). | |
16 | * | |
17 | * Explicitly specifying a length of zero works around this bug, see: | |
18 | * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70932 | |
19 | * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71147 | |
20 | */ | |
21 | #if !defined(__clang__) && defined(__GNUC__) && \ | |
22 | ((__GNUC__ == 6 && __GNUC_MINOR__ >= 1) || ((__GNUC__ == 7 && __GNUC_MINOR__ <= 4))) | |
23 | #define LTTNG_FLEXIBLE_ARRAY_MEMBER_LENGTH 0 | |
24 | #else | |
25 | #define LTTNG_FLEXIBLE_ARRAY_MEMBER_LENGTH | |
26 | #endif /* gcc version [6.1, 7.4]. */ | |
27 | ||
28 | #endif /* LTTNG_COMPILER_HPP */ |