Skip to content

Commit

Permalink
Bogus cast in Time::toString Windows implementation - Close #1283 (#1284
Browse files Browse the repository at this point in the history
)
  • Loading branch information
pepone authored May 28, 2021
1 parent 974af8c commit eaa13ec
Show file tree
Hide file tree
Showing 6 changed files with 307 additions and 36 deletions.
90 changes: 56 additions & 34 deletions cpp/msbuild/ice.test.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2026
# Visual Studio Version 16
VisualStudioVersion = 16.0.31321.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "..\test\Ice\acm\msbuild\client\client.vcxproj", "{CD25A05C-228D-473F-A86F-6C2DD22085B4}"
ProjectSection(ProjectDependencies) = postProject
Expand Down Expand Up @@ -147,7 +147,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "collocated", "..\test\Ice\e
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "..\test\Ice\exceptions\msbuild\server\server.vcxproj", "{24550251-512C-4DC0-9B62-7DB6664DDCA8}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "..\test\Ice\exceptions\msbuild\server\server.vcxproj", "{00000245-0000-0000-0000-000000000000}"
ProjectSection(ProjectDependencies) = postProject
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C}
EndProjectSection
Expand Down Expand Up @@ -1051,7 +1051,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "..\test\IceGrid\s
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "..\test\IceGrid\session\msbuild\server\server.vcxproj", "{35F085D1-34B8-450C-AE23-FCF994DE4879}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "..\test\IceGrid\session\msbuild\server\server.vcxproj", "{00000035-0000-0000-0000-000000000000}"
ProjectSection(ProjectDependencies) = postProject
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C}
EndProjectSection
Expand Down Expand Up @@ -1199,6 +1199,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "persistent", "persistent",
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "..\test\IceStorm\persistent\msbuild\client\client.vcxproj", "{7D48DD81-247D-467E-B94C-D23EC94BDAB0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "time", "time", "{D9C2B6FE-1031-4C1F-883A-D8A8D307C2D4}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "..\test\IceUtil\time\msbuild\client.vcxproj", "{B1C09F91-405B-448C-84FE-1BB4E29CA620}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Cpp11-Debug|Win32 = Cpp11-Debug|Win32
Expand Down Expand Up @@ -1579,22 +1583,22 @@ Global
{3A38F35B-3A61-4490-955D-D1CAE61CB7FD}.Release|Win32.Build.0 = Release|Win32
{3A38F35B-3A61-4490-955D-D1CAE61CB7FD}.Release|x64.ActiveCfg = Release|x64
{3A38F35B-3A61-4490-955D-D1CAE61CB7FD}.Release|x64.Build.0 = Release|x64
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Cpp11-Debug|Win32.ActiveCfg = Cpp11-Debug|Win32
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Cpp11-Debug|Win32.Build.0 = Cpp11-Debug|Win32
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Cpp11-Debug|x64.ActiveCfg = Cpp11-Debug|x64
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Cpp11-Debug|x64.Build.0 = Cpp11-Debug|x64
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Cpp11-Release|Win32.ActiveCfg = Cpp11-Release|Win32
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Cpp11-Release|Win32.Build.0 = Cpp11-Release|Win32
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Cpp11-Release|x64.ActiveCfg = Cpp11-Release|x64
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Cpp11-Release|x64.Build.0 = Cpp11-Release|x64
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Debug|Win32.ActiveCfg = Debug|Win32
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Debug|Win32.Build.0 = Debug|Win32
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Debug|x64.ActiveCfg = Debug|x64
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Debug|x64.Build.0 = Debug|x64
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Release|Win32.ActiveCfg = Release|Win32
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Release|Win32.Build.0 = Release|Win32
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Release|x64.ActiveCfg = Release|x64
{24550251-512C-4DC0-9B62-7DB6664DDCA8}.Release|x64.Build.0 = Release|x64
{00000245-0000-0000-0000-000000000000}.Cpp11-Debug|Win32.ActiveCfg = Cpp11-Debug|Win32
{00000245-0000-0000-0000-000000000000}.Cpp11-Debug|Win32.Build.0 = Cpp11-Debug|Win32
{00000245-0000-0000-0000-000000000000}.Cpp11-Debug|x64.ActiveCfg = Cpp11-Debug|x64
{00000245-0000-0000-0000-000000000000}.Cpp11-Debug|x64.Build.0 = Cpp11-Debug|x64
{00000245-0000-0000-0000-000000000000}.Cpp11-Release|Win32.ActiveCfg = Cpp11-Release|Win32
{00000245-0000-0000-0000-000000000000}.Cpp11-Release|Win32.Build.0 = Cpp11-Release|Win32
{00000245-0000-0000-0000-000000000000}.Cpp11-Release|x64.ActiveCfg = Cpp11-Release|x64
{00000245-0000-0000-0000-000000000000}.Cpp11-Release|x64.Build.0 = Cpp11-Release|x64
{00000245-0000-0000-0000-000000000000}.Debug|Win32.ActiveCfg = Debug|Win32
{00000245-0000-0000-0000-000000000000}.Debug|Win32.Build.0 = Debug|Win32
{00000245-0000-0000-0000-000000000000}.Debug|x64.ActiveCfg = Debug|x64
{00000245-0000-0000-0000-000000000000}.Debug|x64.Build.0 = Debug|x64
{00000245-0000-0000-0000-000000000000}.Release|Win32.ActiveCfg = Release|Win32
{00000245-0000-0000-0000-000000000000}.Release|Win32.Build.0 = Release|Win32
{00000245-0000-0000-0000-000000000000}.Release|x64.ActiveCfg = Release|x64
{00000245-0000-0000-0000-000000000000}.Release|x64.Build.0 = Release|x64
{8D0B611C-F9C2-4B53-8497-7BD8036BD831}.Cpp11-Debug|Win32.ActiveCfg = Cpp11-Debug|Win32
{8D0B611C-F9C2-4B53-8497-7BD8036BD831}.Cpp11-Debug|Win32.Build.0 = Cpp11-Debug|Win32
{8D0B611C-F9C2-4B53-8497-7BD8036BD831}.Cpp11-Debug|x64.ActiveCfg = Cpp11-Debug|x64
Expand Down Expand Up @@ -3755,18 +3759,18 @@ Global
{8EBD7C12-5623-467F-B80D-CFBB4C695771}.Release|Win32.Build.0 = Release|Win32
{8EBD7C12-5623-467F-B80D-CFBB4C695771}.Release|x64.ActiveCfg = Release|x64
{8EBD7C12-5623-467F-B80D-CFBB4C695771}.Release|x64.Build.0 = Release|x64
{35F085D1-34B8-450C-AE23-FCF994DE4879}.Cpp11-Debug|Win32.ActiveCfg = Cpp11-Debug|Win32
{35F085D1-34B8-450C-AE23-FCF994DE4879}.Cpp11-Debug|x64.ActiveCfg = Cpp11-Debug|x64
{35F085D1-34B8-450C-AE23-FCF994DE4879}.Cpp11-Release|Win32.ActiveCfg = Cpp11-Release|Win32
{35F085D1-34B8-450C-AE23-FCF994DE4879}.Cpp11-Release|x64.ActiveCfg = Cpp11-Release|x64
{35F085D1-34B8-450C-AE23-FCF994DE4879}.Debug|Win32.ActiveCfg = Debug|Win32
{35F085D1-34B8-450C-AE23-FCF994DE4879}.Debug|Win32.Build.0 = Debug|Win32
{35F085D1-34B8-450C-AE23-FCF994DE4879}.Debug|x64.ActiveCfg = Debug|x64
{35F085D1-34B8-450C-AE23-FCF994DE4879}.Debug|x64.Build.0 = Debug|x64
{35F085D1-34B8-450C-AE23-FCF994DE4879}.Release|Win32.ActiveCfg = Release|Win32
{35F085D1-34B8-450C-AE23-FCF994DE4879}.Release|Win32.Build.0 = Release|Win32
{35F085D1-34B8-450C-AE23-FCF994DE4879}.Release|x64.ActiveCfg = Release|x64
{35F085D1-34B8-450C-AE23-FCF994DE4879}.Release|x64.Build.0 = Release|x64
{00000035-0000-0000-0000-000000000000}.Cpp11-Debug|Win32.ActiveCfg = Cpp11-Debug|Win32
{00000035-0000-0000-0000-000000000000}.Cpp11-Debug|x64.ActiveCfg = Cpp11-Debug|x64
{00000035-0000-0000-0000-000000000000}.Cpp11-Release|Win32.ActiveCfg = Cpp11-Release|Win32
{00000035-0000-0000-0000-000000000000}.Cpp11-Release|x64.ActiveCfg = Cpp11-Release|x64
{00000035-0000-0000-0000-000000000000}.Debug|Win32.ActiveCfg = Debug|Win32
{00000035-0000-0000-0000-000000000000}.Debug|Win32.Build.0 = Debug|Win32
{00000035-0000-0000-0000-000000000000}.Debug|x64.ActiveCfg = Debug|x64
{00000035-0000-0000-0000-000000000000}.Debug|x64.Build.0 = Debug|x64
{00000035-0000-0000-0000-000000000000}.Release|Win32.ActiveCfg = Release|Win32
{00000035-0000-0000-0000-000000000000}.Release|Win32.Build.0 = Release|Win32
{00000035-0000-0000-0000-000000000000}.Release|x64.ActiveCfg = Release|x64
{00000035-0000-0000-0000-000000000000}.Release|x64.Build.0 = Release|x64
{16EED45E-8D20-40EF-BB30-9DDD5A11B352}.Cpp11-Debug|Win32.ActiveCfg = Cpp11-Debug|Win32
{16EED45E-8D20-40EF-BB30-9DDD5A11B352}.Cpp11-Debug|x64.ActiveCfg = Cpp11-Debug|x64
{16EED45E-8D20-40EF-BB30-9DDD5A11B352}.Cpp11-Release|Win32.ActiveCfg = Cpp11-Release|Win32
Expand Down Expand Up @@ -4159,6 +4163,22 @@ Global
{7D48DD81-247D-467E-B94C-D23EC94BDAB0}.Release|Win32.Build.0 = Release|Win32
{7D48DD81-247D-467E-B94C-D23EC94BDAB0}.Release|x64.ActiveCfg = Release|x64
{7D48DD81-247D-467E-B94C-D23EC94BDAB0}.Release|x64.Build.0 = Release|x64
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Cpp11-Debug|Win32.ActiveCfg = Cpp11-Debug|Win32
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Cpp11-Debug|Win32.Build.0 = Cpp11-Debug|Win32
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Cpp11-Debug|x64.ActiveCfg = Cpp11-Debug|x64
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Cpp11-Debug|x64.Build.0 = Cpp11-Debug|x64
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Cpp11-Release|Win32.ActiveCfg = Cpp11-Release|Win32
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Cpp11-Release|Win32.Build.0 = Cpp11-Release|Win32
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Cpp11-Release|x64.ActiveCfg = Cpp11-Release|x64
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Cpp11-Release|x64.Build.0 = Cpp11-Release|x64
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Debug|Win32.ActiveCfg = Debug|Win32
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Debug|Win32.Build.0 = Debug|Win32
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Debug|x64.ActiveCfg = Debug|x64
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Debug|x64.Build.0 = Debug|x64
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Release|Win32.ActiveCfg = Release|Win32
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Release|Win32.Build.0 = Release|Win32
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Release|x64.ActiveCfg = Release|x64
{B1C09F91-405B-448C-84FE-1BB4E29CA620}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -4201,7 +4221,7 @@ Global
{7D0CD9C9-147B-49F3-BC9C-B2163496F188} = {2CAF9731-CB18-498C-A3EF-24F3D8A334AC}
{6BF6F8F7-AF5F-4A4C-90C2-77473F6AFC2F} = {7D0CD9C9-147B-49F3-BC9C-B2163496F188}
{3A38F35B-3A61-4490-955D-D1CAE61CB7FD} = {7D0CD9C9-147B-49F3-BC9C-B2163496F188}
{24550251-512C-4DC0-9B62-7DB6664DDCA8} = {7D0CD9C9-147B-49F3-BC9C-B2163496F188}
{00000245-0000-0000-0000-000000000000} = {7D0CD9C9-147B-49F3-BC9C-B2163496F188}
{8D0B611C-F9C2-4B53-8497-7BD8036BD831} = {7D0CD9C9-147B-49F3-BC9C-B2163496F188}
{09A35527-2103-4426-BD13-B54D5D953A38} = {2CAF9731-CB18-498C-A3EF-24F3D8A334AC}
{386DD353-1314-407B-A394-476F4983461D} = {09A35527-2103-4426-BD13-B54D5D953A38}
Expand Down Expand Up @@ -4420,7 +4440,7 @@ Global
{D306ADCE-34A1-4599-BD50-8598BB92B47F} = {4FE5DD91-A8BD-4278-B526-DEED12113031}
{3A517759-2BC3-4110-97AA-E5E7E45EA3D8} = {4FE5DD91-A8BD-4278-B526-DEED12113031}
{8EBD7C12-5623-467F-B80D-CFBB4C695771} = {2AD4A6C4-4454-4DD3-9E86-A43FE46B1FAA}
{35F085D1-34B8-450C-AE23-FCF994DE4879} = {2AD4A6C4-4454-4DD3-9E86-A43FE46B1FAA}
{00000035-0000-0000-0000-000000000000} = {2AD4A6C4-4454-4DD3-9E86-A43FE46B1FAA}
{16EED45E-8D20-40EF-BB30-9DDD5A11B352} = {2AD4A6C4-4454-4DD3-9E86-A43FE46B1FAA}
{2B721A85-96F1-4B92-BB31-1BCEF6ACFC8E} = {6B5F8038-66D3-45D9-887B-88BAB9BDD52E}
{C5606B09-9FB7-4337-A490-2024CDCE4036} = {6B5F8038-66D3-45D9-887B-88BAB9BDD52E}
Expand Down Expand Up @@ -4457,6 +4477,8 @@ Global
{0DDD44E0-E425-47BE-8DAA-06CA0E8704D2} = {C167C995-BD18-4BF1-828E-66F7FA0A6BE6}
{372EA6E7-43FD-49F2-A7CB-FC863BAD9E14} = {CEF4EDB3-7782-4B65-9D97-55783C166F4D}
{7D48DD81-247D-467E-B94C-D23EC94BDAB0} = {372EA6E7-43FD-49F2-A7CB-FC863BAD9E14}
{D9C2B6FE-1031-4C1F-883A-D8A8D307C2D4} = {39AA1944-6915-43F5-B219-EC2DA22F6CBC}
{B1C09F91-405B-448C-84FE-1BB4E29CA620} = {D9C2B6FE-1031-4C1F-883A-D8A8D307C2D4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E6FDB68A-64BA-4577-ABCD-40A01257F8AB}
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/IceUtil/Time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ IceUtil::Time::toDateTime() const
os << toString("%x %H:%M:%S") << ".";
os.fill('0');
os.width(3);
os << static_cast<long>(_usec % 1000000 / 1000);
os << static_cast<Int64>(_usec % 1000000 / 1000);
return os.str();
}

Expand Down Expand Up @@ -278,7 +278,7 @@ IceUtil::Time::toDuration() const
std::string
IceUtil::Time::toString(const std::string& format) const
{
time_t time = static_cast<long>(_usec / 1000000);
time_t time = static_cast<time_t>(_usec / 1000000);

struct tm tr;
#ifdef _MSC_VER
Expand Down
36 changes: 36 additions & 0 deletions cpp/test/IceUtil/time/Client.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

#include <IceUtil/Time.h>
#include <TestHelper.h>

using namespace IceUtil;
using namespace std;

class Client : public Test::TestHelper
{
public:

virtual void run(int argc, char* argv[]);
};

void
Client::run(int argc, char*[])
{
if(argc > 1)
{
throw std::invalid_argument("too many arguments");
}

cerr << "testing Time::toString... " << flush;
Time t = Time::now();
test(!t.toDateTime().empty());
// Add forty years to current time to ensure toDateTime works for large values
// see https://github.com/zeroc-ice/ice/issues/1283
t = Time::seconds(t.toSeconds() + (40 * 365 * 24 * 3600));
test(!t.toDateTime().empty());
cerr << "ok" << endl;
}

DEFINE_TEST(Client);
Loading

0 comments on commit eaa13ec

Please sign in to comment.