From 5fdf9ebabcf2126c64a6c09580af7cb91a34c247 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 25 Nov 2020 12:39:04 -0800 Subject: [PATCH] ascii: Note that assertion in UB example may behave arbitrarily. --- ascii/src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ascii/src/lib.rs b/ascii/src/lib.rs index 7e4b856..6dabe44 100644 --- a/ascii/src/lib.rs +++ b/ascii/src/lib.rs @@ -93,7 +93,9 @@ fn bad_ascii() { let bogus: String = ascii.into(); - // `bogus` now holds ill-formed UTF-8. Parsing its first character - // produces a `char` that is not a valid Unicode code point. - assert_eq!(bogus.chars().next().unwrap() as u32, 0x1fffff); + // `bogus` now holds ill-formed UTF-8. Parsing its first character produces + // a `char` that is not a valid Unicode code point. That's undefined + // behavior, so we can't really say what this assertion will do. It could + // pass, fail, crash, do nothing at all, etc. + assert_eq!(bogus.chars().next().unwrap() as u32, 0x1fffff_u32); }