Skip to content

chrono: Questionable usage of treat_as_floating_point_v<_DurationType> #2636

@Dani-Hub

Description

@Dani-Hub

In header <chrono>, line

if (treat_as_floating_point_v<_DurationType> //
, within function _Apply_duration_fields, an if condition contains the expression
treat_as_floating_point_v<_DurationType> where _DurationType represents a std::chrono::duration specialization. But std::chrono::treat_as_floating_point_v ([time.traits.is.fp]) doesn't expect a duration, but performs the test directly on the provided type (usually the representation type of a duration), so this part of the if condition will always evaluate to false, unless a programmer would specialize a duration with a user-provided period or representation type for std::chrono::treat_as_floating_point, which seems unlikely. It seems to me that the mentioned code location intended to use treat_as_floating_point_v<typename _DurationType::rep> instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions