-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
const validation: fix ICE on dangling ZST reference
- Loading branch information
Showing
5 changed files
with
47 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
error: encountered dangling pointer in final value of constant | ||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/dangling-alloc-id-ice.rs:12:1 | ||
| | ||
LL | const FOO: &() = { | ||
| ^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { | ||
HEX_DUMP | ||
} | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Strip out raw byte dumps to make comparison platform-independent: | ||
//@ normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" | ||
//@ normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" | ||
//@ normalize-stderr-test "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" | ||
|
||
pub struct Wrapper; | ||
pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { | ||
//~^ERROR: it is undefined behavior to use this value | ||
std::mem::transmute(&{ | ||
let y = 42; | ||
y | ||
}) | ||
}; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/dangling-zst-ice-issue-126393.rs:7:1 | ||
| | ||
LL | pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { | ||
HEX_DUMP | ||
} | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0080`. |