From c8d82c7599449609d3540eefb7972f137fc1b872 Mon Sep 17 00:00:00 2001 From: torben-hansen <50673096+torben-hansen@users.noreply.github.com> Date: Tue, 20 Feb 2024 13:21:25 -0800 Subject: [PATCH] Reduce compiler ability to optimise to statisfy gcc 9.5 (#1442) gcc 9.5 has a bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189 that has not been backported. Essentially, the compiler will falsely reason that it's comparing a string and optimise out everything behind a null-character. Dropping static const removes optimisation options for the compiler. In my tests, gcc 9.5 now emits a direct memcmp instead of attempting any optimisations. --- ssl/ssl_test.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ssl/ssl_test.cc b/ssl/ssl_test.cc index 26ec2f6af3..4c1f180aef 100644 --- a/ssl/ssl_test.cc +++ b/ssl/ssl_test.cc @@ -4475,7 +4475,10 @@ TEST_P(SSLVersionTest, SessionTimeout) { } TEST_P(SSLVersionTest, DefaultTicketKeyInitialization) { - static const uint8_t kZeroKey[kTicketKeyLen] = {}; + // Do not make static and const. See t/P118709392. + // It can trigger https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189 leading + // to transient errors. + uint8_t kZeroKey[kTicketKeyLen] = {0}; uint8_t ticket_key[kTicketKeyLen]; ASSERT_EQ(1, SSL_CTX_get_tlsext_ticket_keys(server_ctx_.get(), ticket_key, kTicketKeyLen));