From 080c5e6195f5660d741fb930b787c157895c8f99 Mon Sep 17 00:00:00 2001 From: fef Date: Mon, 19 Jul 2021 13:09:27 +0200 Subject: [PATCH] types: make nlen field volatile Compilers might try to be smart and optimize additional reads from a const field away, even if the non-const union member was modified. I do not actually know whether this is the case, but it won't hurt to declare it volatile anyway. --- include/neo/_types.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/neo/_types.h b/include/neo/_types.h index 6d3c22c..dc81596 100644 --- a/include/neo/_types.h +++ b/include/neo/_types.h @@ -43,10 +43,10 @@ typedef long double f128; * * @param name: field name, will be of type `usize` */ -#define NLEN_FIELD(name) \ - union { \ - usize name; \ - const usize __neo_nlen; \ +#define NLEN_FIELD(name) \ + union { \ + usize name; \ + volatile const usize __neo_nlen; \ } struct _neo_nref {