blob: 374ee195dafe3ea8f3ddd5824423b0b89e5916fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
https://issues.chromium.org/issues/423841920
https://chromium-review.googlesource.com/c/chromium/src/+/6633292
From b0ff8c3b258a8816c05bdebf472dbba719d3c491 Mon Sep 17 00:00:00 2001
From: Hans Wennborg <hans@chromium.org>
Date: Tue, 10 Jun 2025 09:51:47 -0700
Subject: [PATCH] Don't return an enum from EnumSizeTraits::Count
`Enum::kMaxValue + 1` may be outside the representable range of the
enum, which Clang will treat as an error in constexpr contexts (see
bug).
Bug: 423841920
Change-Id: I629402cf93bd8419a71f94ff9ed9340d4f88a706
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6633292
Auto-Submit: Hans Wennborg <hans@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Hans Wennborg <hans@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1471871}
--- a/src/3rdparty/chromium/base/metrics/histogram_macros_internal.h
+++ b/src/3rdparty/chromium/base/metrics/histogram_macros_internal.h
@@ -28,16 +28,16 @@
template <typename Enum>
requires(std::is_enum_v<Enum>)
struct EnumSizeTraits {
- static constexpr Enum Count() {
+ static constexpr uintmax_t Count() {
if constexpr (requires { Enum::kMaxValue; }) {
// Since the UMA histogram macros expect a value one larger than the max
// defined enumerator value, add one.
- return static_cast<Enum>(base::to_underlying(Enum::kMaxValue) + 1);
+ return static_cast<uintmax_t>(base::to_underlying(Enum::kMaxValue) + 1);
} else {
static_assert(
sizeof(Enum) == 0,
"enumerator must define kMaxValue enumerator to use this macro!");
- return Enum();
+ return 0;
}
}
};
|