File: constexpr2.patch

package info (click to toggle)
chromium 134.0.6998.117-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 5,929,832 kB
  • sloc: cpp: 34,190,898; ansic: 7,041,458; javascript: 4,034,221; python: 1,459,275; asm: 846,276; xml: 726,586; pascal: 178,372; sh: 104,683; objc: 91,089; perl: 88,388; sql: 48,244; cs: 43,980; makefile: 28,768; fortran: 24,137; php: 20,829; ruby: 17,806; tcl: 10,142; yacc: 8,631; lisp: 3,097; lex: 1,327; ada: 727; awk: 329; jsp: 228; sed: 36
file content (46 lines) | stat: -rw-r--r-- 2,428 bytes parent folder | download | duplicates (2)
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
43
44
45
46
author: Andres Salomon <dilinger@debian.org>
description: same kind of clang/gcc constexpr workaround, except this location is trickier

Clang with gcc-12's libstdc++ can't handle constexpr std::strings; normally we can just make
them const. Because this is inside of a class declaration, it's a bit
more challenging. Use a C-style const char* instead, defaulting to "" and
can be overridden during the constexpr DisplayParams definition.

In file included from ../../ui/display/linux/test/virtual_display_util_linux.cc:5:
In file included from ../../ui/display/linux/test/virtual_display_util_linux.h:12:
../../ui/display/test/virtual_display_util.h:63:34: error: constexpr variable 'k1920x1080' must be initialized by a constant expression
  static constexpr DisplayParams k1920x1080 = {gfx::Size(1920, 1080)};
                                 ^            ~~~~~~~~~~~~~~~~~~~~~~~
../../ui/display/test/virtual_display_util.h:63:34: note: pointer to subobject of heap-allocated object is not a constant expression
/usr/bin/../include/c++/v1/__memory/allocator.h:113:38: note: heap allocation performed here
            return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
                                     ^

--- a/ui/display/test/virtual_display_util.h
+++ b/ui/display/test/virtual_display_util.h
@@ -19,21 +19,21 @@ namespace test {
 struct DISPLAY_EXPORT DisplayParams {
   gfx::Size resolution;
   gfx::Vector2d dpi = gfx::Vector2d(96, 96);
-  std::string description;
+  const char* description = "";
 };
 
 bool constexpr operator<(const display::test::DisplayParams& a,
                          const display::test::DisplayParams& b) {
   return std::tuple(a.resolution.width(), a.resolution.height(), a.dpi.x(),
-                    a.dpi.y(), a.description) <
+                    a.dpi.y(), std::string(a.description)) <
          std::tuple(b.resolution.width(), b.resolution.height(), b.dpi.x(),
-                    b.dpi.y(), b.description);
+                    b.dpi.y(), std::string(b.description));
 }
 
 bool constexpr operator==(const display::test::DisplayParams& a,
                           const display::test::DisplayParams& b) {
   return a.resolution == b.resolution && a.dpi == b.dpi &&
-         a.description == b.description;
+         std::string(a.description) == std::string(b.description);
 }
 
 // This interface creates system-level virtual displays to support the automated