Remove #ifdef from cooked-index-entry.c

Message ID 20261028172301.1376846-1-tromey@adacore.com
State New
Headers
Series Remove #ifdef from cooked-index-entry.c |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Tom Tromey Oct. 28, 2026, 5:23 p.m. UTC
  cooked-index-entry.c has an #ifdef to work around a GCC 7.5.0 bug.
However, the workaround just removes a 'constexpr' which is not
needed.  The constexpr behavior was desirable in the past, but this
changed with commit 8cbf7d2a ("gdb/dwarf: remove unnecessary
comparison in cooked_index_entry::compare").

This removes the #ifdef and the constexpr.
---
 gdb/dwarf2/cooked-index-entry.c | 5 -----
 1 file changed, 5 deletions(-)


base-commit: aeed64b39aed57729f66ad51560d8964e8201e6e
  

Comments

Simon Marchi Oct. 28, 2026, 5:33 p.m. UTC | #1
On 10/28/26 1:23 PM, Tom Tromey wrote:
> cooked-index-entry.c has an #ifdef to work around a GCC 7.5.0 bug.
> However, the workaround just removes a 'constexpr' which is not
> needed.  The constexpr behavior was desirable in the past, but this
> changed with commit 8cbf7d2a ("gdb/dwarf: remove unnecessary
> comparison in cooked_index_entry::compare").
> 
> This removes the #ifdef and the constexpr.

Nit: it's an #if, not an #ifdef.

For my curiosity, can you explain why constexpr was needed (or useful) in the first place?

The commit that added it is:

https://gitlab.com/gnutools/binutils-gdb/-/commit/2e724489260d02a528591eaea4710ce5aeeee0e8

but it doesn't talk about that.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Thanks,

Simon
  
Tom Tromey Oct. 28, 2026, 9:23 p.m. UTC | #2
Simon> For my curiosity, can you explain why constexpr was needed (or
Simon> useful) in the first place?

I added a note to the commit message but basically:

Simon> The commit that added it is:
Simon> https://gitlab.com/gnutools/binutils-gdb/-/commit/2e724489260d02a528591eaea4710ce5aeeee0e8
Simon> but it doesn't talk about that.

... the old code called "munge ('<')" which is a constant.
Though perhaps that was wishful thinking and/or maybe an older patch did
something else.

Tom
  

Patch

diff --git a/gdb/dwarf2/cooked-index-entry.c b/gdb/dwarf2/cooked-index-entry.c
index 44b065157b8..c76c263117a 100644
--- a/gdb/dwarf2/cooked-index-entry.c
+++ b/gdb/dwarf2/cooked-index-entry.c
@@ -47,12 +47,7 @@  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