|
|
Created:
4 years, 4 months ago by liberato (no reviews please) Modified:
4 years, 4 months ago CC:
chromium-reviews Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionAdd explicit TimeDelta constexpr copy constructor.
MSVC fails to initialize constexpr TimeDelta instances in some
situations. It turns out (thanks brucedawson@) that including
an explicit constexpr copy constructor works around this.
BUG=635974
Committed: https://crrev.com/f4831ddd84ec8f068fb934a6de94560e202c01eb
Cr-Commit-Position: refs/heads/master@{#411805}
Patch Set 1 #
Total comments: 6
Patch Set 2 : cl feedback -- windows only #
Total comments: 1
Messages
Total messages: 21 (8 generated)
Description was changed from ========== Add explicit TimeDelta constexpr copy constructor. MSVC fails to initialize constexpr TimeDelta instances in some instances. It turns out that including a constexpr copy constructor works around this. BUG=635974 ========== to ========== Add explicit TimeDelta constexpr copy constructor. MSVC fails to initialize constexpr TimeDelta instances in some situations. It turns out (thanks brucedawson@) that including an explicit constexpr copy constructor works around this. BUG=635974 ==========
liberato@chromium.org changed reviewers: + brucedawson@chromium.org, miu@chromium.org
hi all miu: PTAL for owner review. thanks -fl
https://codereview.chromium.org/2241603002/diff/1/base/time/time.h File base/time/time.h (right): https://codereview.chromium.org/2241603002/diff/1/base/time/time.h#newcode246 base/time/time.h:246: constexpr TimeDelta(const TimeDelta& other) : delta_(other.delta_) {} Since the bug is Windows-specific, please surround this new ctor with: #if defined(OS_WIN) ... #endif // defined(OS_WIN) https://codereview.chromium.org/2241603002/diff/1/base/time/time_unittest.cc File base/time/time_unittest.cc (right): https://codereview.chromium.org/2241603002/diff/1/base/time/time_unittest.cc#... base/time/time_unittest.cc:25: enum { kExpectedDeltaInMilliseconds = 10 }; Is it necessary for this to be an enum to trigger the compiler error? Otherwise, nit: Please make this constexpr int64_t kExpected... = 10; https://codereview.chromium.org/2241603002/diff/1/base/time/time_unittest.cc#... base/time/time_unittest.cc:1101: TEST(TimeDelta, ConstexprInitialization) { Please put these changes in time_win_unittest.cc instead, since they're addressing a Windows compiler-specific bug.
i'm hoping that the flurry of CRLF translations during upload ended up in the right place... thanks -fl https://codereview.chromium.org/2241603002/diff/1/base/time/time.h File base/time/time.h (right): https://codereview.chromium.org/2241603002/diff/1/base/time/time.h#newcode246 base/time/time.h:246: constexpr TimeDelta(const TimeDelta& other) : delta_(other.delta_) {} On 2016/08/11 21:48:56, miu wrote: > Since the bug is Windows-specific, please surround this new ctor with: > > #if defined(OS_WIN) > ... > #endif // defined(OS_WIN) Done. https://codereview.chromium.org/2241603002/diff/1/base/time/time_unittest.cc File base/time/time_unittest.cc (right): https://codereview.chromium.org/2241603002/diff/1/base/time/time_unittest.cc#... base/time/time_unittest.cc:25: enum { kExpectedDeltaInMilliseconds = 10 }; On 2016/08/11 21:48:56, miu wrote: > Is it necessary for this to be an enum to trigger the compiler error? Otherwise, > nit: Please make this constexpr int64_t kExpected... = 10; it's not necessary. originally, i had it as constexpr. it seemed a bit like a red-herring, given the subject of the test. i'll switch it back. https://codereview.chromium.org/2241603002/diff/1/base/time/time_unittest.cc#... base/time/time_unittest.cc:1101: TEST(TimeDelta, ConstexprInitialization) { On 2016/08/11 21:48:56, miu wrote: > Please put these changes in time_win_unittest.cc instead, since they're > addressing a Windows compiler-specific bug. Done.
lgtm
On 2016/08/11 22:37:47, miu wrote: > lgtm Have you confirmed that the test fails without the workaround in time.h?
On 2016/08/11 23:12:32, brucedawson wrote: > On 2016/08/11 22:37:47, miu wrote: > > lgtm > > Have you confirmed that the test fails without the workaround in time.h? yes.
lgtm
The CQ bit was checked by liberato@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_chromium_asan_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by liberato@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== Add explicit TimeDelta constexpr copy constructor. MSVC fails to initialize constexpr TimeDelta instances in some situations. It turns out (thanks brucedawson@) that including an explicit constexpr copy constructor works around this. BUG=635974 ========== to ========== Add explicit TimeDelta constexpr copy constructor. MSVC fails to initialize constexpr TimeDelta instances in some situations. It turns out (thanks brucedawson@) that including an explicit constexpr copy constructor works around this. BUG=635974 ==========
Message was sent while issue was closed.
Committed patchset #2 (id:20001)
Message was sent while issue was closed.
Description was changed from ========== Add explicit TimeDelta constexpr copy constructor. MSVC fails to initialize constexpr TimeDelta instances in some situations. It turns out (thanks brucedawson@) that including an explicit constexpr copy constructor works around this. BUG=635974 ========== to ========== Add explicit TimeDelta constexpr copy constructor. MSVC fails to initialize constexpr TimeDelta instances in some situations. It turns out (thanks brucedawson@) that including an explicit constexpr copy constructor works around this. BUG=635974 Committed: https://crrev.com/f4831ddd84ec8f068fb934a6de94560e202c01eb Cr-Commit-Position: refs/heads/master@{#411805} ==========
Message was sent while issue was closed.
Patchset 2 (id:??) landed as https://crrev.com/f4831ddd84ec8f068fb934a6de94560e202c01eb Cr-Commit-Position: refs/heads/master@{#411805}
Message was sent while issue was closed.
jyasskin@chromium.org changed reviewers: + jyasskin@chromium.org
Message was sent while issue was closed.
Thanks for doing this. https://codereview.chromium.org/2241603002/diff/20001/base/time/time_win_unit... File base/time/time_win_unittest.cc (right): https://codereview.chromium.org/2241603002/diff/20001/base/time/time_win_unit... base/time/time_win_unittest.cc:300: EXPECT_EQ(kExpectedDeltaInMilliseconds, kConstexprTimeDelta.InMilliseconds()); You're testing a bug in constexpr variables, so you shouldn't really use constexpr variables on both sides of the EXPECT_EQ: the bug could cancel itself out. I think that's unlikely in this case because of the nature of the bug, but it'd be a better test with a literal '10' there. |