)]}'
{
  "commit": "7d8c59a3a7ec5c3d79bb4c554389f6b69b0b9be9",
  "tree": "e0e700df9f6ef2699e738d06c1b53e192278e964",
  "parents": [
    "f2f78087c2235e9e3156d0651be26660005a03a1"
  ],
  "author": {
    "name": "Tejas Anil Nagmote",
    "email": "tejasnagmote520@gmail.com",
    "time": "Tue Oct 13 16:17:16 2026"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Tue Oct 13 16:17:16 2026"
  },
  "message": "Support DoNotOptimize on types with const members (#1997) (#2291)\n\n* Fall back to an asm input operand for non-writable types\n\nDoNotOptimize passes its argument as a read-write asm operand, but an\nobject of a class type with a const data member cannot be stored into,\nso gcc rejects it (\"read-only reference used as \u0027asm\u0027 output\") and clang\nrejects it (\"invalid lvalue in asm output\"). Since the const-ref overload\nis deprecated, such a type had no usable spelling at all -- most visibly\nin generic code, where DoNotOptimize is reached through a deduced\nnon-const reference.\n\nRoute those types to an input operand instead. The memory clobber is\nretained, so the compiler still has to place the object in memory and\nstill cannot assume it unchanged across the asm.\n\nThere is no trait for \"has a const data member\", so assignability stands\nin for it. Arrays are never assignable but are valid outputs, so they are\nallowed outright. A class with a reference data member is a valid output\ntoo but is indistinguishable by trait, so it conservatively takes the\ninput operand as well.\n\nFixes #1997\n\n* Cover const-member types in donotoptimize_test\n\nExercises DoNotOptimize with register-sized and larger-than-register\ntypes holding a const data member, as lvalues, as rvalues, and through a\ndeduced non-const reference -- the reproducer from issue #1997. Every one\nof these fails to compile without the preceding change.\n\n* Use r,m / m,r for the DoNotOptimize input fallback\n\nThe fallback for types that cannot be asm outputs now uses the same\nregister-or-memory alternatives as the other overloads, r,m for clang\nand m,r for gcc, instead of plain m. A small type with a const member\ncan then stay in a register instead of being spilled to the stack.\n\nChecked with gcc 5-15 and clang 3.9-20 at -O0 and -O2 in C++11,\nincluding large types and ones that are not trivially copyable.\n\n* Simplify the DoNotOptimize input fallback\n\nUse a single forwarding-reference overload for the non-writable case.\nThe separate lvalue-reference overload was redundant: unlike the\nread-write overloads, an input operand imposes no constraint that\nrequires distinguishing lvalues from rvalues.\n\nDrop the compiler-dependent operand order as well. The r,m / m,r split\nmatters only for the read-write (\"+\") operand, where GCC rejects\n\"+r,m\" at -O2; for a pure input operand both orders are accepted by\nGCC and Clang, and the existing DoNotOptimize(Tp const\u0026) overloads\nalready use \"r,m\" unconditionally.\n\n---------\n\nCo-authored-by: dominic \u003c510002+dmah42@users.noreply.github.com\u003e\nCo-authored-by: Roman Lebedev \u003clebedev.ri@gmail.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "dccd3b218d7268f87c0f64981a37f51ecdb32615",
      "old_mode": 33188,
      "old_path": "include/benchmark/utils.h",
      "new_id": "4a10c874cc58f2a71a7ce7f610fdba5f92cdba77",
      "new_mode": 33188,
      "new_path": "include/benchmark/utils.h"
    },
    {
      "type": "modify",
      "old_id": "34b1ed64791753726c25d22073f828eb6297b642",
      "old_mode": 33188,
      "old_path": "test/donotoptimize_test.cc",
      "new_id": "5a025d74baea82b226a54c77325a94d4f8ad0598",
      "new_mode": 33188,
      "new_path": "test/donotoptimize_test.cc"
    }
  ]
}
