From: Hugo Landau Date: Thu, 8 Feb 2024 09:41:23 +0000 (+0000) Subject: JSON_ENC: Fix unit test for MSVC X-Git-Tag: openssl-3.3.0-alpha1~124 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1260d0f5792b5253ecd8ca23eee848ab2c50c1ea;p=thirdparty%2Fopenssl.git JSON_ENC: Fix unit test for MSVC Previously scripts were defined like this: { static const char *const script_name = "xxx"; static const struct script_info script_info = { script_name, ... }; return &script_info; } MSVC cannot handle this, presumably because this technically involves a load from a variable to determine that script_name equals "xxx" and it is unable to do this during evaluation of a constant initializer list. Resolve this by changing script_name and script_title to be arrays instead, allowing the correct pointer values to be filled into script_info as symbol addresses/relocations rather than dereferences. Reviewed-by: Tomas Mraz Reviewed-by: Tom Cosgrove Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/23517) --- diff --git a/test/json_test.c b/test/json_test.c index d2c5059719..8cde1be2e3 100644 --- a/test/json_test.c +++ b/test/json_test.c @@ -128,8 +128,8 @@ typedef void (*fp_pz_type)(OSSL_JSON_ENC *, const void *, size_t); #define BEGIN_SCRIPT(name, title, flags) \ static const struct script_info *get_script_##name(void) \ { \ - const char *const script_name = #name; \ - const char *const script_title = #title; \ + static const char script_name[] = #name; \ + static const char script_title[] = #title; \ \ static const struct script_word script_words[] = { \ OP_INIT_FLAGS(flags)