From 18ba67df507b0c4560200b444f37dce07c6fc803 Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Mon, 5 Jun 2023 15:54:08 -0400 Subject: [PATCH] gccrs: Prevent initialization related warnings/errors for Optional https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635#c53 gcc/rust/ChangeLog: * util/rust-optional.h (class Optional): Add volatile field to union. Signed-off-by: Owen Avery --- gcc/rust/util/rust-optional.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/rust/util/rust-optional.h b/gcc/rust/util/rust-optional.h index 30880cd41db0..e545c1596cee 100644 --- a/gcc/rust/util/rust-optional.h +++ b/gcc/rust/util/rust-optional.h @@ -86,6 +86,10 @@ private: union { T value; + // prevents initialization warnings + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635#c53 + // FIXME: remove + volatile char unused; }; Optional (tag_some, const T &value) : field_is_some (true), value (value) {} -- 2.47.2