Skip to content

Commit cc7303c

Browse files
Chris Manghaneianlancetaylor
Chris Manghane
authored andcommitted
compiler: Don't crash on invalid print call.
When the print builtins are called with no arguments, the compiler issues a warning and crashes when trying to produce the backend representation for the arguments. Fixes golang/go#11526. Change-Id: I0616bfdd4f29cedeb44db51a311e706d4628c19c Reviewed-on: https://go-review.googlesource.com/13131 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent ec34cfb commit cc7303c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

go/expressions.cc

+6
Original file line numberDiff line numberDiff line change
@@ -8177,6 +8177,12 @@ Builtin_call_expression::do_get_backend(Translate_context* context)
81778177
location);
81788178
}
81798179

8180+
// There aren't any arguments to the print builtin. The compiler
8181+
// issues a warning for this so we should avoid getting the backend
8182+
// representation for this call. Instead, perform a no-op.
8183+
if (print_stmts == NULL)
8184+
return context->backend()->boolean_constant_expression(false);
8185+
81808186
return print_stmts->get_backend(context);
81818187
}
81828188

0 commit comments

Comments
 (0)