]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
compiler: correct condition for calling memclrHasPointers
authorIan Lance Taylor <iant@golang.org>
Fri, 10 Sep 2021 18:14:25 +0000 (11:14 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 10 Sep 2021 18:14:45 +0000 (11:14 -0700)
When compiling append(s, make([]typ, ln)...), where typ has a pointer,
and the append fits within the existing capacity of s, the condition
used to clear out the new elements was reversed.

Fixes golang/go#47771

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/344189

gcc/go/gofrontend/expressions.cc

index 6375922dac1254e012992e0d7e6b6868884d903d..de8399f8231ff42e85a586b50423e9603fab8452 100644 (file)
@@ -9169,7 +9169,7 @@ Builtin_call_expression::flatten_append(Gogo* gogo, Named_object* function,
               ref2 = Expression::make_cast(uint_type, ref2, loc);
               cond = Expression::make_binary(OPERATOR_GT, ref, ref2, loc);
               zero = Expression::make_integer_ul(0, int_type, loc);
-              call = Expression::make_conditional(cond, call, zero, loc);
+              call = Expression::make_conditional(cond, zero, call, loc);
             }
         }
       else