diff options
author | Pedro Alves <pedro@palves.net> | 2023-12-21 10:43:20 +0000 |
---|---|---|
committer | Pedro Alves <pedro@palves.net> | 2023-12-21 11:07:32 +0000 |
commit | bfcfa995f9461726d57f0d9a2879ba4352547870 (patch) | |
tree | 86121b12f1992327318c0aa62df802a16fc46aa8 /.gitattributes | |
parent | 3a4ee6286814e850f66d84b6b8b18cd053649d35 (diff) | |
download | gdb-bfcfa995f9461726d57f0d9a2879ba4352547870.zip gdb-bfcfa995f9461726d57f0d9a2879ba4352547870.tar.gz gdb-bfcfa995f9461726d57f0d9a2879ba4352547870.tar.bz2 |
Fix Clang build issue with flexible array member and non-trivial dtor
Commit d5cebea18e7a ("Make cached_reg_t own its data") added a
destructor to cached_reg_t.
That caused a build problem with Clang, which errors out like so:
> CXX python/py-unwind.o
> gdb/python/py-unwind.c:126:16: error: flexible array member 'reg' of type 'cached_reg_t[]' with non-trivial destruction
> 126 | cached_reg_t reg[];
> | ^
This is is not really a problem for our code, which allocates the
whole structure with xmalloc, and then initializes the array elements
with in-place new, and then takes care to call the destructor
manually. Like, commit d5cebea18e7a did:
@@ -928,7 +927,7 @@ pyuw_dealloc_cache (frame_info *this_frame, void *cache)
cached_frame_info *cached_frame = (cached_frame_info *) cache;
for (int i = 0; i < cached_frame->reg_count; i++)
- xfree (cached_frame->reg[i].data);
+ cached_frame->reg[i].~cached_reg_t ();
Maybe we should get rid of the flexible array member and use a bog
standard std::vector. I doubt this would cause any visible
performance issue.
Meanwhile, to unbreak the build, this commit switches from C99-style
flexible array member to 0-length array. It behaves the same, and
Clang doesn't complain. I got the idea from here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70932#c11
GCC 9, our oldest support version, already supported this:
https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Zero-Length.html
but the extension is actually much older than that. Note that
C99-style flexible array members are not standard C++ either.
Change-Id: I37dda18f367e238a41d610619935b2a0f2acacce
Diffstat (limited to '.gitattributes')
0 files changed, 0 insertions, 0 deletions