From 6bfb2c933e0fece60d9b3ddf27df6e63f0c84940 Mon Sep 17 00:00:00 2001 From: Joseph Schuchart Date: Fri, 29 Apr 2022 18:19:08 -0400 Subject: [PATCH] Fix offset detection in attr_subsys_construct It appears that GCC starting from GCC 11 optimizes out the offset detection. By moving the pointers used for testing out of the function into TU scope we can suppress that optimization. Signed-off-by: Joseph Schuchart --- ompi/attribute/attribute.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ompi/attribute/attribute.c b/ompi/attribute/attribute.c index cfe2ac387e5..542bb2007dc 100644 --- a/ompi/attribute/attribute.c +++ b/ompi/attribute/attribute.c @@ -476,6 +476,8 @@ static attr_subsys_t *attr_subsys = NULL; static unsigned int int_pos = 12345; static unsigned int integer_pos = 12345; static int attr_sequence; +static void *dummy = (void*)1; +static int *p = (void*)&dummy; /* * MPI attributes are *not* high performance, so just use a One Big Lock @@ -574,8 +576,6 @@ int ompi_attr_put_ref(void) static void attr_subsys_construct(attr_subsys_t *subsys) { int ret; - void *bogus = (void*) 1; - int *p = (int *) &bogus; subsys->keyval_hash = OBJ_NEW(opal_hash_table_t);