Fix gcc compilation error.
QUICHE fails to compile with gcc with the following error message:
quic/core/quic_crypto_stream.cc: In constructor 'QuicCryptoStream::QuicCryptoStream(QuicSession*)':
quic/core/quic_crypto_stream.cc:39:52: error: use of deleted function 'QuicCryptoStream::CryptoSubstream::CryptoSubstream(QuicCryptoStream::CryptoSubstream&&)'
{this, ENCRYPTION_FORWARD_SECURE}} {
^
In file included from quic/core/quic_crypto_stream.cc:5:
quic/core/quic_crypto_stream.h:158:30: note: 'QuicCryptoStream::CryptoSubstream::CryptoSubstream(QuicCryptoStream::CryptoSubstream&&)' is implicitly deleted because the default definition would be ill-formed:
struct QUIC_EXPORT_PRIVATE CryptoSubstream {
^~~~~~~~~~~~~~~
quic/core/quic_crypto_stream.h:158:30: error: use of deleted function 'QuicStreamSendBuffer::QuicStreamSendBuffer(QuicStreamSendBuffer&&)'
In file included from quic/core/quic_stream.h:27,
from quic/core/quic_crypto_stream.h:15,
from quic/core/quic_crypto_stream.cc:5:
quic/core/quic_stream_send_buffer.h:65:3: note: declared here
QuicStreamSendBuffer(QuicStreamSendBuffer&& other) = delete;
^~~~~~~~~~~~~~~~~~~~
This CL changes QuicCryptoStrem::substreams_ type from array to std::array, and
uses aggregate initialization instead of initializer list as required for
std::array. See also
https://stackoverflow.com/questions/8192185/using-stdarray-with-initialization-lists
I manually confirmed that this compiles in Chromium using clang, and compiles in
Envoy using either gcc or clang. I have no idea why.
gfe-relnote: n/a, no functional change.
PiperOrigin-RevId: 284051434
Change-Id: I936020d8847e8109e73b9ffe1493ca1b74e159dc
diff --git a/quic/core/quic_crypto_stream.cc b/quic/core/quic_crypto_stream.cc
index e22e830..3bc94e8 100644
--- a/quic/core/quic_crypto_stream.cc
+++ b/quic/core/quic_crypto_stream.cc
@@ -33,10 +33,10 @@
QuicVersionUsesCryptoFrames(session->transport_version())
? CRYPTO
: BIDIRECTIONAL),
- substreams_{{this, ENCRYPTION_INITIAL},
- {this, ENCRYPTION_HANDSHAKE},
- {this, ENCRYPTION_ZERO_RTT},
- {this, ENCRYPTION_FORWARD_SECURE}} {
+ substreams_{{{this, ENCRYPTION_INITIAL},
+ {this, ENCRYPTION_HANDSHAKE},
+ {this, ENCRYPTION_ZERO_RTT},
+ {this, ENCRYPTION_FORWARD_SECURE}}} {
// The crypto stream is exempt from connection level flow control.
DisableConnectionFlowControlForThisStream();
}
diff --git a/quic/core/quic_crypto_stream.h b/quic/core/quic_crypto_stream.h
index 357303a..10b0b53 100644
--- a/quic/core/quic_crypto_stream.h
+++ b/quic/core/quic_crypto_stream.h
@@ -5,6 +5,7 @@
#ifndef QUICHE_QUIC_CORE_QUIC_CRYPTO_STREAM_H_
#define QUICHE_QUIC_CORE_QUIC_CRYPTO_STREAM_H_
+#include <array>
#include <cstddef>
#include <string>
@@ -178,7 +179,7 @@
// Keeps state for data sent/received in CRYPTO frames at each encryption
// level.
- CryptoSubstream substreams_[NUM_ENCRYPTION_LEVELS];
+ std::array<CryptoSubstream, NUM_ENCRYPTION_LEVELS> substreams_;
};
} // namespace quic