From: Pierre-Emmanuel Patry <[email protected]>

The str variable was left in an unspecified but valid state after the
prior move on the same line. This lead to a value of zero on some
platforms and the prefix was considered empty.

gcc/rust/ChangeLog:

        * lex/rust-lex.cc (Lexer::parse_decimal_int_or_float): Prevent use
        after move.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: 
https://github.com/Rust-GCC/gccrs/commit/6db350e65b68b17a194dfb2f1203f7e1c1da49d7

The commit has NOT been mentioned in any issue.

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4579

 gcc/rust/lex/rust-lex.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc
index 900e5890f..4f135b19a 100644
--- a/gcc/rust/lex/rust-lex.cc
+++ b/gcc/rust/lex/rust-lex.cc
@@ -2306,7 +2306,8 @@ Lexer::parse_decimal_int_or_float (location_t loc)
       loc += length - 1;
 
       str.shrink_to_fit ();
-      return Token::make_float (loc, std::move (str), str.length (),
+      auto suffix_start = str.length ();
+      return Token::make_float (loc, std::move (str), suffix_start,
                                CORETYPE_UNKNOWN);
     }
   else if (current_char == 'E' || current_char == 'e')

base-commit: 0b1424eca415ca70c719d3ca4251d5cedcb0982a
-- 
2.54.0

Reply via email to