Misleading error message in constexpr function when variable is uninitialized #51536
Labels
bugzilla
Issues migrated from bugzilla
c++11
clang:diagnostics
New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Uh oh!
There was an error while loading. Please reload this page.
Extended Description
Minimal example:
When I compile this on Godbolt using the "x86-64 clang (trunk)" branch and the -std=c++20 flag I get the following error message:
This is misleading because the actual problem is that sum was not initialized. If sum is initialized with sum=0 then there is no error. This problem exists for other modify and assign operators as well. Using separate assignment and equality operators does not have this problem. For example:
Give this error message:
Which correctly identifies that the problem is that sum is uninitialized.
The text was updated successfully, but these errors were encountered: