summaryrefslogtreecommitdiffstats
path: root/src/test/ui/issues/issue-82833-slice-miscompile.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/issues/issue-82833-slice-miscompile.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-82833-slice-miscompile.rs b/src/test/ui/issues/issue-82833-slice-miscompile.rs
new file mode 100644
index 000000000..8cf6a3137
--- /dev/null
+++ b/src/test/ui/issues/issue-82833-slice-miscompile.rs
@@ -0,0 +1,16 @@
+// run-pass
+// compile-flags: -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Copt-level=0 -Cdebuginfo=2
+
+// Make sure LLVM does not miscompile this.
+
+fn make_string(ch: char) -> String {
+ let mut bytes = [0u8; 4];
+ ch.encode_utf8(&mut bytes).into()
+}
+
+fn main() {
+ let ch = '😃';
+ dbg!(ch);
+ let string = make_string(ch);
+ dbg!(string);
+}