This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Fix msp430 build with gcc-5
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Thu, 5 Feb 2015 09:47:21 +1030
- Subject: Fix msp430 build with gcc-5
- Authentication-results: sourceware.org; auth=none
gcc-5 correctly complains "loop exit may only be reached after
undefined behavior". I was going to correct this by checking the
index before dereferencing the array rather than the other way around,
but then I noticed it is possible for extract_cmd to write the
terminating zero one past the end of "cmd". Fixing that means no
index check is needed in md_assemble (and we do need "cmd" to be zero
terminated).
* config/tc-msp430.c (md_assemble): Correct size passed to
extract_cmd. Remove index check.
diff --git a/gas/config/tc-msp430.c b/gas/config/tc-msp430.c
index e44e7b2..2891c13 100644
--- a/gas/config/tc-msp430.c
+++ b/gas/config/tc-msp430.c
@@ -3174,9 +3174,9 @@ md_assemble (char * str)
unsigned int i = 0;
str = skip_space (str); /* Skip leading spaces. */
- str = extract_cmd (str, cmd, sizeof (cmd));
+ str = extract_cmd (str, cmd, sizeof (cmd) - 1);
- while (cmd[i] && i < sizeof (cmd))
+ while (cmd[i])
{
char a = TOLOWER (cmd[i]);
cmd[i] = a;
--
Alan Modra
Australia Development Lab, IBM