Skip to content

No warning for implicit narrowing conversion during constant evaluation #92656

@katzdm

Description

@katzdm

The fixes for C++23 P2564 merged by #89565 expanded the class of constant evaluated variable initializers. This inadvertently resulted in some warnings no longer diagnosing, e.g.,

constexpr char h = u'\u5678';  // previously diagnosed warn_impcast_integer_precision_constant

A suggested approach is to mark both diagnoses of warn_impcast_integer_precision_constant as DiagRuntimeBehavior (which was previously the case), and to separately diagnose in the constant evaluator. This could be done by deducing narrowing during evaluation, or by marking narrowing expressions during semantic analysis and thereafter diagnosing if any such expressions are evaluated. Ideally, the above would diagnose, but an initializer like the following would not:

constexpr char h = (true ? 'a' : u'\u5678');

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerfalse-negativeWarning doesn't fire when it should

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions