Add underlying type to Balsa enums.

Otherwise the static_cast<ParseState>(-1) in HTTPBalsaFrame.ParseStateToString
in is undefined behavior.

The C++ standard states: "A value of integral or enumeration type can be
explicitly converted to a complete enumeration type.  If the enumeration type
has a fixed underlying type, the value is [...] converted [...] to the
enumeration type.  If the enumeration type does not have a fixed underlying
type, the value is unchanged if the original value is within the range of the
enumeration values, and otherwise, the behavior is undefined."  See
(The actual standard is not available for free, this is an official draft.)

In other words, conversion of any value is well-defined if the enum has an
underlying type, but not otherwise.

I can reproduce by compiling the following example:

enum ParseState {

int main() {
  ParseState state = static_cast<ParseState>(8);
  return state + 2;

clang -fsanitize=undefined -l:libstdc++.a && ./a.out runtime error: load of value 8, which is not a valid value for type 'ParseState'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior in

And if I add ParseState : int, the error goes away.

This was caught by Envoy ASAN CI, and is blocking Balsa integration to Envoy.

Once here, add underlying type to all enums in balsa_enums.h.

PiperOrigin-RevId: 448474661
1 file changed
tree: 8d3c123dcd6d16acb2283ff377cb8aa37d0638d9
  1. quiche/


QUICHE stands for QUIC, Http, Etc. It is Google‘s production-ready implementation of QUIC, HTTP/2, HTTP/3, and related protocols and tools. It powers Google’s servers, Chromium, Envoy, and other projects. It is actively developed and maintained.

There are two public QUICHE repositories. Either one may be used by embedders, as they are automatically kept in sync:

To embed QUICHE in your project, platform APIs need to be implemented and build files need to be created. Note that it is on the QUICHE team's roadmap to include default implementation for all platform APIs and to open-source build files. In the meanwhile, take a look at open source embedders like Chromium and Envoy to get started:

To contribute to QUICHE, follow instructions at

QUICHE is only supported on little-endian platforms.