Skip to content

Constant evaluation failure reports an error on each use-site #32842

@retep998

Description

@retep998

In the past few days winapi was hit with a deluge of this warning (266 of them to be precise): warning: constant evaluation error: attempted to subtract with overflow. This will become a HARD ERROR in the future, #[warn(const_err)] on by default

I can't say I'm too thrilled as winapi makes use of this pattern quite a bit in defining constants: pub const LVN_DELETEALLITEMS: ::UINT = LVN_FIRST - 4;

The workaround is kinda ugly: pub const LVN_DELETEALLITEMS: ::UINT = (LVN_FIRST as ::INT - 4) as ::UINT;

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions