Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duration cast missing when using 'ard µsec #431

Open
thirtytwobits opened this issue Feb 2, 2025 · 2 comments
Open

duration cast missing when using 'ard µsec #431

thirtytwobits opened this issue Feb 2, 2025 · 2 comments
Labels
domain-production Pertains to the shippable code rather than any scaffolding
Milestone

Comments

@thirtytwobits
Copy link
Contributor

We need to search for all places in the code that do this:

 TimePoint{std::chrono::microseconds{out_transfer.timestamp_usec}};

and replace them with this:

 TimePoint{std::chrono::duration_cast<Duration>(std::chrono::microseconds{out_transfer.timestamp_usec})};
@pavel-kirienko pavel-kirienko added class-defect domain-production Pertains to the shippable code rather than any scaffolding and removed class-defect labels Feb 4, 2025
@serges147
Copy link
Collaborator

@thirtytwobits @pavel-kirienko Please elaborate - I don't see what is the issue here. I believe that constructor # 4 does exactly that: https://en.cppreference.com/w/cpp/chrono/duration/duration

@serges147
Copy link
Collaborator

ok now I see it - constr#4 does it only if:

This overload participates in overload resolution only if no overflow is induced in the conversion, and any of the following conditions is satisfied:...

So, it will compile fine if I change our TimePoint::period to nanoseconds (b/c 10^9 divisible by 10^6 without reminder), BUT it fails to compile if I try use milliseconds (b/c (10^3 % 10^6) != 0) - this is the case when you have to use the explicit duration_cast, kinda being ok with potential precision loss.
@thirtytwobits Could you please confirm, that this is exactly (as I suppose you tried milliseconds) what you have encountered?

@thirtytwobits thirtytwobits added this to the v1.0 milestone Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain-production Pertains to the shippable code rather than any scaffolding
Projects
None yet
Development

No branches or pull requests

3 participants