Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.4.19 fails to build: s2n_ktls_io.c: error: variable-sized object may not be initialized except with an empty initializer #4673

Open
barracuda156 opened this issue Jul 30, 2024 · 2 comments · May be fixed by #4674

Comments

@barracuda156
Copy link

This does not build with C99 anymore:

[ 71%] Building C object CMakeFiles/s2n.dir/tls/s2n_prf.c.o
/opt/local/bin/ccache /opt/local/bin/gcc-mp-14 -DS2N_ATOMIC_SUPPORTED -DS2N_CLOEXEC_SUPPORTED -DS2N_CLOEXEC_XOPEN_SUPPORTED -DS2N_DIAGNOSTICS_POP_SUPPORTED -DS2N_DIAGNOSTICS_PUSH_SUPPORTED -DS2N_EXECINFO_AVAILABLE -DS2N_FALL_THROUGH_SUPPORTED -DS2N_LIBCRYPTO_SUPPORTS_EVP_MD5_SHA1_HASH -DS2N_LIBCRYPTO_SUPPORTS_EVP_MD_CTX_SET_PKEY_CTX -DS2N_LIBCRYPTO_SUPPORTS_EVP_RC4 -DS2N_LIBCRYPTO_SUPPORTS_FLAG_NO_CHECK_TIME -DS2N_LIBCRYPTO_SUPPORTS_RSA_PSS_SIGNING -DS2N_LIBCRYPTO_SUPPORTS_X509_STORE_LIST -DS2N_MADVISE_SUPPORTED -DS2N_MINHERIT_SUPPORTED -DS2N_STACKTRACE -D_POSIX_C_SOURCE=200809L -Ds2n_EXPORTS -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19 -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19/api -isystem /opt/local/include -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -arch ppc -mmacosx-version-min=10.6 -fPIC -pedantic -std=gnu99 -Wall -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-align -Wwrite-strings -Wno-deprecated-declarations -Wno-unknown-pragmas -Wformat-security -Wno-missing-braces -Wsign-compare -Wno-strict-prototypes -Werror -fvisibility=hidden -DS2N_EXPORTS -fPIC -MD -MT CMakeFiles/s2n.dir/tls/s2n_prf.c.o -MF CMakeFiles/s2n.dir/tls/s2n_prf.c.o.d -o CMakeFiles/s2n.dir/tls/s2n_prf.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19/tls/s2n_prf.c
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19/tls/s2n_ktls_io.c: In function 's2n_ktls_sendmsg':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19/tls/s2n_ktls_io.c:214:55: error: variable-sized object may not be initialized except with an empty initializer
  214 |     char control_data[S2N_KTLS_CONTROL_BUFFER_SIZE] = { 0 };
      |                                                       ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19/tls/s2n_ktls_io.c: In function 's2n_ktls_recvmsg':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19/tls/s2n_ktls_io.c:257:55: error: variable-sized object may not be initialized except with an empty initializer
  257 |     char control_data[S2N_KTLS_CONTROL_BUFFER_SIZE] = { 0 };
      |                                                       ^
make[2]: *** [CMakeFiles/s2n.dir/tls/s2n_ktls_io.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/build'
make[1]: *** [CMakeFiles/s2n.dir/all] Error 2
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/build'
make: *** [all] Error 2
@barracuda156
Copy link
Author

Ah, it is just broken, regardless of standard.

gcc 14 with c11, same story:

[ 71%] Building C object CMakeFiles/s2n.dir/tls/s2n_prf.c.o
/opt/local/bin/ccache /opt/local/bin/gcc-mp-14 -DS2N_ATOMIC_SUPPORTED -DS2N_CLOEXEC_SUPPORTED -DS2N_CLOEXEC_XOPEN_SUPPORTED -DS2N_DIAGNOSTICS_POP_SUPPORTED -DS2N_DIAGNOSTICS_PUSH_SUPPORTED -DS2N_EXECINFO_AVAILABLE -DS2N_FALL_THROUGH_SUPPORTED -DS2N_LIBCRYPTO_SUPPORTS_EVP_MD5_SHA1_HASH -DS2N_LIBCRYPTO_SUPPORTS_EVP_MD_CTX_SET_PKEY_CTX -DS2N_LIBCRYPTO_SUPPORTS_EVP_RC4 -DS2N_LIBCRYPTO_SUPPORTS_FLAG_NO_CHECK_TIME -DS2N_LIBCRYPTO_SUPPORTS_RSA_PSS_SIGNING -DS2N_LIBCRYPTO_SUPPORTS_X509_STORE_LIST -DS2N_MADVISE_SUPPORTED -DS2N_MINHERIT_SUPPORTED -DS2N_STACKTRACE -D_POSIX_C_SOURCE=200809L -Ds2n_EXPORTS -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19 -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19/api -isystem /opt/local/include -pipe -Os -DNDEBUG -isystem/opt/local/include/LegacySupport -I/opt/local/include -arch ppc -mmacosx-version-min=10.6 -fPIC -pedantic -std=gnu11 -Wall -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-align -Wwrite-strings -Wno-deprecated-declarations -Wno-unknown-pragmas -Wformat-security -Wno-missing-braces -Wsign-compare -Wno-strict-prototypes -Werror -fvisibility=hidden -DS2N_EXPORTS -fPIC -MD -MT CMakeFiles/s2n.dir/tls/s2n_prf.c.o -MF CMakeFiles/s2n.dir/tls/s2n_prf.c.o.d -o CMakeFiles/s2n.dir/tls/s2n_prf.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19/tls/s2n_prf.c
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19/tls/s2n_ktls_io.c: In function 's2n_ktls_sendmsg':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19/tls/s2n_ktls_io.c:214:55: error: variable-sized object may not be initialized except with an empty initializer
  214 |     char control_data[S2N_KTLS_CONTROL_BUFFER_SIZE] = { 0 };
      |                                                       ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19/tls/s2n_ktls_io.c: In function 's2n_ktls_recvmsg':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.19/tls/s2n_ktls_io.c:257:55: error: variable-sized object may not be initialized except with an empty initializer
  257 |     char control_data[S2N_KTLS_CONTROL_BUFFER_SIZE] = { 0 };
      |                                                       ^
make[2]: *** [CMakeFiles/s2n.dir/tls/s2n_ktls_io.c.o] Error 1

Apple clang of Catalina:

/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.18/tls/s2n_ktls_io.c:214:23: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant]
    char control_data[S2N_KTLS_CONTROL_BUFFER_SIZE] = { 0 };
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.18/tls/s2n_ktls_io.c:43:38: note: expanded from macro 'S2N_KTLS_CONTROL_BUFFER_SIZE'
#define S2N_KTLS_CONTROL_BUFFER_SIZE (CMSG_SPACE(S2N_KTLS_RECORD_TYPE_SIZE))
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.18/tls/s2n_ktls_io.c:214:23: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.18/tls/s2n_ktls_io.c:43:39: note: expanded from macro 'S2N_KTLS_CONTROL_BUFFER_SIZE'
#define S2N_KTLS_CONTROL_BUFFER_SIZE (CMSG_SPACE(S2N_KTLS_RECORD_TYPE_SIZE))
                                      ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/socket.h:652:34: note: expanded from macro 'CMSG_SPACE'
#define CMSG_SPACE(l)           (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l))
                                 ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/i386/_param.h:43:42: note: expanded from macro '__DARWIN_ALIGN32'
#define       __DARWIN_ALIGN32(p)       ((__darwin_size_t)((char *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32)
                                         ^
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.18/tls/s2n_ktls_io.c:257:23: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant]
    char control_data[S2N_KTLS_CONTROL_BUFFER_SIZE] = { 0 };
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.18/tls/s2n_ktls_io.c:43:38: note: expanded from macro 'S2N_KTLS_CONTROL_BUFFER_SIZE'
#define S2N_KTLS_CONTROL_BUFFER_SIZE (CMSG_SPACE(S2N_KTLS_RECORD_TYPE_SIZE))
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.18/tls/s2n_ktls_io.c:257:23: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_security_s2n-tls/s2n-tls/work/s2n-tls-1.4.18/tls/s2n_ktls_io.c:43:39: note: expanded from macro 'S2N_KTLS_CONTROL_BUFFER_SIZE'
#define S2N_KTLS_CONTROL_BUFFER_SIZE (CMSG_SPACE(S2N_KTLS_RECORD_TYPE_SIZE))
                                      ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/socket.h:652:34: note: expanded from macro 'CMSG_SPACE'
#define CMSG_SPACE(l)           (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l))
                                 ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/i386/_param.h:43:42: note: expanded from macro '__DARWIN_ALIGN32'
#define       __DARWIN_ALIGN32(p)       ((__darwin_size_t)((char *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32)
                                         ^
2 errors generated.
make[2]: *** [CMakeFiles/s2n.dir/tls/s2n_ktls_io.c.o] Error 1

@barracuda156 barracuda156 changed the title Does not build with C99: s2n_ktls_io.c: error: variable-sized object may not be initialized except with an empty initializer 1.4.19 fails to build: s2n_ktls_io.c: error: variable-sized object may not be initialized except with an empty initializer Jul 30, 2024
@barracuda156
Copy link
Author

Wait, I have a fix for this.

barracuda156 added a commit to barracuda156/s2n-tls that referenced this issue Jul 30, 2024
@lrstewart lrstewart linked a pull request Aug 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant