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

No warning for implicit narrowing conversion during constant evaluation #92656

Open
katzdm opened this issue May 18, 2024 · 0 comments
Open

No warning for implicit narrowing conversion during constant evaluation #92656

katzdm opened this issue May 18, 2024 · 0 comments
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-negative

Comments

@katzdm
Copy link
Contributor

katzdm commented May 18, 2024

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');
@katzdm katzdm changed the title No warning generated for implicit narrowing conversion during constant evaluation No warning for implicit narrowing conversion during constant evaluation May 18, 2024
@EugeneZelenko EugeneZelenko added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-negative and removed new issue labels May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-negative
Projects
None yet
Development

No branches or pull requests

2 participants