Skip to content

Fix type precision warning in Xcode 9#56

Merged
cameron314 merged 1 commit intocameron314:masterfrom
jonathonracz:master
Nov 9, 2017
Merged

Fix type precision warning in Xcode 9#56
cameron314 merged 1 commit intocameron314:masterfrom
jonathonracz:master

Conversation

@jonathonracz
Copy link
Copy Markdown
Contributor

Nothing more than it says in the title. Xcode 9 was (rightfully) complaining about the std::int64_t data being downcast to an unsigned int (the type of the tv_sec field), so I silenced it with a static cast.

This is unlikely to cause issues since the usec-scale time is being divided by 1000000 to convert to sec.

@cameron314
Copy link
Copy Markdown
Owner

Thanks! :-)
Any idea why this is not a problem for tv_nsec as well?

@cameron314 cameron314 merged commit 373392d into cameron314:master Nov 9, 2017
@jonathonracz
Copy link
Copy Markdown
Contributor Author

I would presume the constant 1000 multiplicand is being implicitly cast to tv_nsec's clock_res_t (int) type during the assignment of the result, and is also implicitly casting the (timeout_usecs % 1000000) by being a multiplicand.

Definitely not implicit casting clang wizardry I (or most people) would use naturally, but I guess it just so happened to work out.

@cameron314
Copy link
Copy Markdown
Owner

The right-hand expression is compiled independently of the assignment context, so the implicit cast to int must be done just before the assignment. I guess there's only a warning when mixing signed/unsigned types. MSVC would have warned here, I think. Hmm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants