compiling BoringSSL with gcc higher than g++-11 on Debian testing fails with:
ninja: Entering directory `build/'
[459/751] Building C object crypto/CMakeFiles/crypto.dir/bytestring/cbb.c.o
FAILED: crypto/CMakeFiles/crypto.dir/bytestring/cbb.c.o
/usr/bin/cc -DBORINGSSL_IMPLEMENTATION -Ipath/to/lib/boringssl/include -Werror -Wformat=2 -Wsign-compare -Wwrite-strings -Wvla -Wshadow -Wtype-limits -ggdb -Wall -fvisibility=hidden -fno-common -Wno-free-nonheap-object -Wimplicit-fallthrough -Wformat-signedness -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes -D_XOPEN_SOURCE=700 -O3 -DNDEBUG -std=gnu11 -MD -MT crypto/CMakeFiles/crypto.dir/bytestring/cbb.c.o -MF crypto/CMakeFiles/crypto.dir/bytestring/cbb.c.o.d -o crypto/CMakeFiles/crypto.dir/bytestring/cbb.c.o -c path/to/lib/boringssl/crypto/bytestring/cbb.c
In function ‘cbb_add_child’,
inlined from ‘CBB_add_asn1’ at path/to/lib/boringssl/crypto/bytestring/cbb.c:361:10,
inlined from ‘CBB_add_asn1’ at path/to/lib/boringssl/crypto/bytestring/cbb.c:342:5,
inlined from ‘CBB_add_asn1_octet_string’ at path/to/lib/boringssl/crypto/bytestring/cbb.c:544:8:
path/to/lib/boringssl/crypto/bytestring/cbb.c:291:14: error: storing the address of local variable ‘child’ in ‘*cbb.child’ [-Werror=dangling-pointer=]
291 | cbb->child = out_child;
| ~~~~~~~~~~~^~~~~~~~~~~
path/to/lib/boringssl/crypto/bytestring/cbb.c: In function ‘CBB_add_asn1_octet_string’:
path/to/lib/boringssl/crypto/bytestring/cbb.c:543:7: note: ‘child’ declared here
543 | CBB child;
| ^~~~~
path/to/lib/boringssl/crypto/bytestring/cbb.c:542:36: note: ‘cbb’ declared here
542 | int CBB_add_asn1_octet_string(CBB *cbb, const uint8_t *data, size_t data_len) {
| ~~~~~^~~
In function ‘cbb_add_child’,
inlined from ‘CBB_add_asn1’ at path/to/lib/boringssl/crypto/bytestring/cbb.c:361:10,
inlined from ‘CBB_add_asn1’ at path/to/lib/boringssl/crypto/bytestring/cbb.c:342:5,
inlined from ‘CBB_add_asn1_bool’ at path/to/lib/boringssl/crypto/bytestring/cbb.c:555:8:
path/to/lib/boringssl/crypto/bytestring/cbb.c:291:14: error: storing the address of local variable ‘child’ in ‘*cbb.child’ [-Werror=dangling-pointer=]
291 | cbb->child = out_child;
| ~~~~~~~~~~~^~~~~~~~~~~
path/to/lib/boringssl/crypto/bytestring/cbb.c: In function ‘CBB_add_asn1_bool’:
path/to/lib/boringssl/crypto/bytestring/cbb.c:554:7: note: ‘child’ declared here
554 | CBB child;
| ^~~~~
path/to/lib/boringssl/crypto/bytestring/cbb.c:553:28: note: ‘cbb’ declared here
553 | int CBB_add_asn1_bool(CBB *cbb, int value) {
| ~~~~~^~~
cc1: all warnings being treated as errors
[472/751] Building CXX object CMakeFiles/ssl_test.dir/ssl/ssl_test.cc.o
ninja: build stopped: subcommand failed.
Steps:
git clone https://github.com/google/boringssl.git
cd boringssl
cmake -DCMAKE_CXX_COMPILER=g++-12 -DCMAKE_BUILD_TYPE=Release -B build -GNinja
ninja -C build
Works with g++-11. Didn't try with gcc-10 because I don't care.
Any idea how to make it work with g++-12 or 13?
Thanks
Update:
For those interested, here is the issue on their bug tracker: