aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/go-gcc.cc
diff options
context:
space:
mode:
authorChris Manghane <cmang@google.com>2015-09-10 18:24:28 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2015-09-10 18:24:28 +0000
commitec23e5b3950ab5a907aecdb0860340b86702ed13 (patch)
treec3d6323633f32f5fef3f497f47e7bb3718941bd3 /gcc/go/go-gcc.cc
parent8b661145105bf5d8d7be3f2e57b51c8b8d2c27b7 (diff)
downloadgcc-ec23e5b3950ab5a907aecdb0860340b86702ed13.zip
gcc-ec23e5b3950ab5a907aecdb0860340b86702ed13.tar.gz
gcc-ec23e5b3950ab5a907aecdb0860340b86702ed13.tar.bz2
compiler: Report errors from very large types.
The gcc backend throws an internal error when trying to get the size of a type which is larger than the amount of address space on the machine. This patch catches this error and reports it in a user friendly way. Fixes golang/go#11554. Reviewed-on: https://go-review.googlesource.com/13684 * go-gcc.cc (Gcc_backend::type_size): Return -1 for unrepresentable size. From-SVN: r227656
Diffstat (limited to 'gcc/go/go-gcc.cc')
-rw-r--r--gcc/go/go-gcc.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
index cb4c2e5..1314344 100644
--- a/gcc/go/go-gcc.cc
+++ b/gcc/go/go-gcc.cc
@@ -1099,7 +1099,8 @@ Gcc_backend::type_size(Btype* btype)
gcc_assert(tree_fits_uhwi_p (t));
unsigned HOST_WIDE_INT val_wide = TREE_INT_CST_LOW(t);
int64_t ret = static_cast<int64_t>(val_wide);
- gcc_assert(ret >= 0 && static_cast<unsigned HOST_WIDE_INT>(ret) == val_wide);
+ if (ret < 0 || static_cast<unsigned HOST_WIDE_INT>(ret) != val_wide)
+ return -1;
return ret;
}