diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-10-10 18:21:34 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-10-10 18:21:34 +0200 |
| commit | 373c362b7ed0df2dfbc21853e53d5082f20d3de8 (patch) | |
| tree | 7905e19b6c9d9fae62392ae076f04e7626684266 | |
| parent | 76fe6a41ba156b59a78c162c0c1b0fadd02dd3f6 (diff) | |
| download | rust-373c362b7ed0df2dfbc21853e53d5082f20d3de8.tar.gz rust-373c362b7ed0df2dfbc21853e53d5082f20d3de8.zip | |
Check that we don't access nonexisting union fields
| -rw-r--r-- | src/librustc_target/abi/mod.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index 26d37f196be..fde5c5bed4d 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -738,7 +738,11 @@ impl FieldPlacement { pub fn offset(&self, i: usize) -> Size { match *self { - FieldPlacement::Union(_) => Size::ZERO, + FieldPlacement::Union(count) => { + assert!(i < count, + "Tried to access field {} of union with {} fields", i, count); + Size::ZERO + }, FieldPlacement::Array { stride, count } => { let i = i as u64; assert!(i < count); |
