)]}'
{
  "commit": "bf3a11997dbcbc6fc44924ec515fcfc582588d45",
  "tree": "8d3c123dcd6d16acb2283ff377cb8aa37d0638d9",
  "parents": [
    "e69b1f5fc4e0a8e73361f00b2077826cb547d4a9"
  ],
  "author": {
    "name": "bnc",
    "email": "bnc@google.com",
    "time": "Fri May 13 05:39:06 2022 -0700"
  },
  "committer": {
    "name": "Copybara-Service",
    "email": "copybara-worker@google.com",
    "time": "Fri May 13 05:40:08 2022 -0700"
  },
  "message": "Add underlying type to Balsa enums.\n\nOtherwise the static_cast\u003cParseState\u003e(-1) in HTTPBalsaFrame.ParseStateToString\nin balsa_frame_test.cc is undefined behavior.\n\nThe C++ standard states: \"A value of integral or enumeration type can be\nexplicitly converted to a complete enumeration type.  If the enumeration type\nhas a fixed underlying type, the value is [...] converted [...] to the\nenumeration type.  If the enumeration type does not have a fixed underlying\ntype, the value is unchanged if the original value is within the range of the\nenumeration values, and otherwise, the behavior is undefined.\"  See\nhttps://github.com/cplusplus/draft/blob/193a67c9f17e3d7102061e8e01250562b6292351/source/expressions.tex#L4005-L4017\n(The actual standard is not available for free, this is an official draft.)\n\nIn other words, conversion of any value is well-defined if the enum has an\nunderlying type, but not otherwise.\n\nI can reproduce by compiling the following example:\n\nenum ParseState {\n  A,\n  B,\n  C,\n};\n\nint main() {\n  ParseState state \u003d static_cast\u003cParseState\u003e(8);\n  return state + 2;\n}\n\nclang enum.cc -fsanitize\u003dundefined -l:libstdc++.a \u0026\u0026 ./a.out\n\nenum.cc:11:10: runtime error: load of value 8, which is not a valid value for type \u0027ParseState\u0027\nSUMMARY: UndefinedBehaviorSanitizer: undefined-behavior enum.cc:11:10 in\n\nAnd if I add ParseState : int, the error goes away.\n\nThis was caught by Envoy ASAN CI, and is blocking Balsa integration to Envoy.\nSee\nhttps://dev.azure.com/cncf/envoy/_build/results?buildId\u003d108238\u0026view\u003dlogs\u0026j\u003d1439b9f7-a348-5b50-b5fe-ea612ea91241\u0026t\u003d37b0a9be-1a71-50b3-594a-4c04a031247d.\n\nOnce here, add underlying type to all enums in balsa_enums.h.\n\nPiperOrigin-RevId: 448474661\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "2c067b6ee47a855f0fc31f68425d80c54a687d55",
      "old_mode": 33188,
      "old_path": "quiche/balsa/balsa_enums.h",
      "new_id": "9302881f89bedcbd296301e6aa93e4981e40bfef",
      "new_mode": 33188,
      "new_path": "quiche/balsa/balsa_enums.h"
    }
  ]
}
