]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/build] Fix build with gcc 7.5.0
authorTom de Vries <tdevries@suse.de>
Mon, 27 Jan 2025 15:38:32 +0000 (16:38 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 27 Jan 2025 15:38:32 +0000 (16:38 +0100)
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 <tom@tromey.com>
gdb/dwarf2/cooked-index.c

index e024c78cf51406f51f404bdd8b152dd5d81eda29..1b08ba4c52b2d52cc75a2768f38fb153d40b7d79 100644 (file)
@@ -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<t>" match "func<t<int>>".  See the "Breakpoints in