[binutils-gdb] GAS: Change S parameter of find_no_app to CHAR* in order to avoid problems with STRSTR returning a C

Nick Clifton nickc@sourceware.org
Mon Dec 8 09:12:17 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8e992ccb1e4e351f52516af713cff1a3191df640

commit 8e992ccb1e4e351f52516af713cff1a3191df640
Author: Nick Clifton <nickc@redhat.com>
Date:   Mon Dec 8 09:11:23 2025 +0000

    GAS: Change S parameter of find_no_app to CHAR* in order to avoid problems with STRSTR returning a CONST CHAR*
    
    PR 33696

Diff:
---
 gas/read.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/gas/read.c b/gas/read.c
index 4ba71f99250..23fa4c67534 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -858,16 +858,24 @@ do_align (unsigned int n, char *fill, unsigned int len, unsigned int max)
 }
 
 /* Find first <eol><next_char>NO_APP<eol>, if any, in the supplied buffer.
-   Return NULL if there's none, or else the position of <next_char>.  */
+   Return NULL if there's none, or else the position of <next_char>.
+   
+   Note: the S parameter to this function is typed as CHAR* rather than
+   CONST CHAR* because if it is const then the strstr() function will return
+   a const pointer, which in turn means that the END local would need to be
+   const, which would mean that the function itself would have to return a
+   const pointer, which means that input_line_pointer would have to become
+   const, which would break lots of things.  (See PR 33696).  */
+
 static char *
-find_no_app (const char *s, char next_char)
+find_no_app (char *s, char next_char)
 {
   const char *start = s;
   const char srch[] = { next_char, 'N', 'O', '_', 'A', 'P', 'P', '\0' };
 
   for (;;)
     {
-      char *ends = strstr (s, srch);
+      char * ends = strstr (s, srch);
 
       if (ends == NULL)
 	break;


More information about the Binutils-cvs mailing list