Skip to content

Commit

Permalink
compiler: Don't crash on invalid arithmetic ops.
Browse files Browse the repository at this point in the history
The gofrontend would crash after hitting an unreachable state while
trying to determine the type of an arithmetic expression involving
non-numeric values.  Instead of crashing, it should fail gracefully
if the relevant error is already reported.

Fixes golang/go#11537.

Change-Id: I84ec06bb944b8af34ec5e5864a5149c11c782919
Reviewed-on: https://go-review.googlesource.com/13793
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
Chris Manghane authored and ianlancetaylor committed Aug 26, 2015
1 parent d5e6af4 commit cd5362c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion go/expressions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15150,7 +15150,11 @@ Numeric_constant::set_type(Type* type, bool issue_error, Location loc)
else if (type->complex_type() != NULL)
ret = this->check_complex_type(type->complex_type(), issue_error, loc);
else
go_unreachable();
{
ret = false;
if (issue_error)
go_assert(saw_errors());
}
if (ret)
this->type_ = type;
return ret;
Expand Down

0 comments on commit cd5362c

Please sign in to comment.