arm: uninitialised exp.X_op

Alan Modra <[email protected]>
Newsgroups gmane.comp.gnu.binutils
Message-ID <[email protected]>
On Sun, Aug 09, 2026 at 06:15:37PM +0930, Alan Modra wrote:
> exp.X_op can indeed be used uninitialised.  You found a real error,

Really, I think my_get_expression return status ought to be tested
everywhere the function is called, to trim multiple error messages if
for no other reason.  I'm going to leave that change to one of the ARM
maintainers if they feel so inclined.  Meanwhile make this obvious fix.

	* config/tc-arm.c (my_get_expression): Move initialisation of
	expression before first return from function.

diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index ba599ef1fda..c02d3101cc1 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -1141,6 +1141,8 @@ my_get_expression (expressionS * ep, char ** str, int prefix_mode)
 {
   char * save_in;
 
+  memset (ep, 0, sizeof (expressionS));
+
   /* In unified syntax, all prefixes are optional.  */
   if (unified_syntax)
     prefix_mode = (prefix_mode == GE_OPT_PREFIX_BIG) ? prefix_mode
@@ -1166,8 +1168,6 @@ my_get_expression (expressionS * ep, char ** str, int prefix_mode)
       abort ();
     }
 
-  memset (ep, 0, sizeof (expressionS));
-
   save_in = input_line_pointer;
   input_line_pointer = *str;
   in_my_get_expression = true;

-- 
Alan Modra
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.