[llvm-commits] [llvm] r115503 - /llvm/trunk/unittests/Support/System.cpp
Francois Pichet
pichet2000 at gmail.com
Wed Oct 6 22:23:07 PDT 2010
On Mon, Oct 4, 2010 at 8:22 PM, John Tytgat <john at bass-software.com> wrote:
> In message <20101004123120.4CCB62A6C130 at llvm.org>
> Francois Pichet <pichet2000 at gmail.com> wrote:
>
>> Author: fpichet
>> Date: Mon Oct 4 07:31:20 2010
>> New Revision: 115503
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=115503&view=rev
>> Log:
>> static_cast to long, otherwise MSVC 2008 won't compile.
>>
>> Modified:
>> llvm/trunk/unittests/Support/System.cpp
>>
>> Modified: llvm/trunk/unittests/Support/System.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/System.cpp?rev=115503&r1=115502&r2=115503&view=diff
>> ==============================================================================
>> --- llvm/trunk/unittests/Support/System.cpp (original)
>> +++ llvm/trunk/unittests/Support/System.cpp Mon Oct 4 07:31:20 2010
>> @@ -11,6 +11,6 @@
>> TEST_F(SystemTest, TimeValue) {
>> sys::TimeValue now = sys::TimeValue::now();
>> time_t now_t = time(NULL);
>> - EXPECT_TRUE(abs(static_cast<time_t>(now_t - now.toEpochTime())) < 2);
>> + EXPECT_TRUE(abs(static_cast<long>(now_t - now.toEpochTime())) < 2);
>
> I might be wrong but this doesn't feel Win64 safe as 'long' is still 32-bit
> while 'time_t' is 64-bit wide (of course only when the time difference would
> be 1<<32 +/- 1).
Hi sorry for the late reply. No this is not Win64 in theory but in
practice the time difference will be very small (most likely 0) so
casting from a 64 bit to a 32 bit doesn't matter. I don't have a
better solution since there is no abs() for 64 bit in MSVC 2008.
Without the cast there is a compilation error as MSVC doesn't know
which abs to call.
More information about the llvm-commits
mailing list