From: Tom de Vries Date: Mon, 27 Jan 2025 15:38:32 +0000 (+0100) Subject: [gdb/build] Fix build with gcc 7.5.0 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=163d99117597022dbcb70f5da6a03646876c2f5f;p=thirdparty%2Fbinutils-gdb.git [gdb/build] Fix build with gcc 7.5.0 When building gdb with gcc 7.5.0, I run into: ... gdb/dwarf2/cooked-index.c: In lambda function: gdb/dwarf2/cooked-index.c:104:5: error: \ the value of ‘_sch_tolower’ is not usable in a constant expression }; ^ In file included from gdbsupport/gdb-safe-ctype.h:47:0, from gdb/dwarf2/cooked-index.c:34: include/safe-ctype.h:111:29: note: ‘_sch_tolower’ was not declared ‘constexpr’ extern const unsigned char _sch_tolower[256]; ^~~~~~~~~~~~ ... This does not happen with gcc 8.2.1. Fix this by dropping the constexpr on lambda function munge in cooked_index_entry::compare for gcc 7. Tested by completing the build on x86_64-linux. Approved-By: Tom Tromey --- diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index e024c78cf51..1b08ba4c52b 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -93,7 +93,12 @@ int cooked_index_entry::compare (const char *stra, const char *strb, comparison_mode mode) { +#if defined (__GNUC__) && !defined (__clang__) && __GNUC__ <= 7 + /* Work around error with gcc 7.5.0. */ + auto munge = [] (char c) -> unsigned char +#else auto munge = [] (char c) constexpr -> unsigned char +#endif { /* Treat '<' as if it ended the string. This lets something like "func" match "func>". See the "Breakpoints in