Skip to content

<chrono>: No diagnostic for truncating conversion of chrono duration #1040

Description

Describe the bug
Chrono does not emit any compile-time warning when truncating duration

Command-line test case


d:\Temp2>type repro.cpp
#pragma warning(disable:4820) // '%d' bytes padding added after data member '%s'
#pragma warning(disable:4514) // '%s': unreferenced inline function has been removed

#include <chrono>

void f(std::chrono::duration<unsigned long, std::milli>) {}

int main() {
    f(std::chrono::duration<unsigned long long, std::milli>{ 10000000000000000000ULL });
    return 0;
}
d:\Temp2>cl /EHsc /W4 /Wall /WX .\repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.27.29009.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

repro.cpp
Microsoft (R) Incremental Linker Version 14.27.29009.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:repro.exe
repro.obj

Expected behavior
A warning

STL version

Microsoft Visual Studio Professional 2019 Preview
Version 16.7.0 Preview 3.1

Additional context
Also tracked by DevCom-671799 and VSO-961527 / AB#961527 .

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions