compiler: use temporary to avoid early destruction

The code was passing a substr directly to strtol, and then checking
the *end value returned by strtol.  But the substr could be destroyed
as soon as strtol returns, making the test of *end invalid.

Also fix an incorrect test of the string index rather than the value.

Fixes https://gcc.gnu.org/PR90110

Change-Id: I020a26249ab00d5828621a0ec120e3f7c790df2e
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/172663
Reviewed-by: Than McIntosh <thanm@google.com>
1 file changed