https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81448
Bug ID: 81448
Summary: False positive -Werror=multistatement-macros in
openssl
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: bernd.edlinger at hotmail dot de
Target Milestone: ---
building openssl with ./config --strict-warnings
fails due to -Werror=multistatement-macros
I see no obvious way how to work around that:
gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include
-DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -Wa,--noexecstack
-m64 -DL_ENDIAN -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT
-DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM
-DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM
-DGHASH_ASM -DECP_NISTZ256_ASM -pedantic -DPEDANTIC -Wno-long-long
-Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wundef -Werror
-DCRYPTO_MDEBUG_ALL -DCRYPTO_MDEBUG_ABORT -DREF_CHECK -DOPENSSL_NO_DEPRECATED
-c -o e_bf.o e_bf.c
In file included from e_bf.c:63:0:
e_bf.c: In function 'bf_ecb_cipher':
e_bf.c:76:32: error: macro expands to multiple statements
[-Werror=multistatement-macros]
IMPLEMENT_BLOCK_CIPHER(bf, ks, BF, EVP_BF_KEY, NID_bf, 8, 16, 8, 64,
^~
evp_locl.h:75:17: note: in definition of macro 'BLOCK_CIPHER_func_ecb'
cprefix##_ecb_encrypt(in + i, out + i, &((kstruct
*)ctx->cipher_data)->ksched, ctx->encrypt);\
^~~~~~~
evp_locl.h:250:9: note: in expansion of macro 'BLOCK_CIPHER_all_funcs'
BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
^~~~~~~~~~~~~~~~~~~~~~
e_bf.c:76:1: note: in expansion of macro 'IMPLEMENT_BLOCK_CIPHER'
IMPLEMENT_BLOCK_CIPHER(bf, ks, BF, EVP_BF_KEY, NID_bf, 8, 16, 8, 64,
^~~~~~~~~~~~~~~~~~~~~~
evp_locl.h:69:9: note: some parts of macro expansion are not guarded by this
'for' clause
for(i=0; i <= inl; i+=bl)
^~~
evp_locl.h:74:9: note: in expansion of macro 'BLOCK_CIPHER_ecb_loop'
BLOCK_CIPHER_ecb_loop() \
^~~~~~~~~~~~~~~~~~~~~
evp_locl.h:131:9: note: in expansion of macro 'BLOCK_CIPHER_func_ecb'
BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
^~~~~~~~~~~~~~~~~~~~~
evp_locl.h:250:9: note: in expansion of macro 'BLOCK_CIPHER_all_funcs'
BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
^~~~~~~~~~~~~~~~~~~~~~
e_bf.c:76:1: note: in expansion of macro 'IMPLEMENT_BLOCK_CIPHER'
IMPLEMENT_BLOCK_CIPHER(bf, ks, BF, EVP_BF_KEY, NID_bf, 8, 16, 8, 64,
^~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [e_bf.o] Error 1
make[2]: Leaving directory `/home/ed/OPC/openssl/crypto/evp'
make[1]: *** [subdirs] Error 1
make[1]: Leaving directory `/home/ed/OPC/openssl/crypto'
make: *** [build_crypto] Error 1
this is in evp_locl.h (as of openssl 1.0.2):
#define BLOCK_CIPHER_ecb_loop() \
size_t i, bl; \
bl = ctx->cipher->block_size;\
if(inl < bl) return 1;\
inl -= bl; \
for(i=0; i <= inl; i+=bl)
#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const
unsigned char *in, size_t inl) \
{\
BLOCK_CIPHER_ecb_loop() \
cprefix##_ecb_encrypt(in + i, out + i, &((kstruct
*)ctx->cipher_data)->ksched, ctx->encrypt);\
return 1;\
}
and cprefix##_ecb_encrypt expands to BF_ecb_encrypt which
is a single function call.