https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120210
Bug ID: 120210
Summary: [12/13/14/15 Regression] std::array like class gives
an maybe-uninitialized warning on size() function
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Blocks: 116697
Target Milestone: ---
Like PR 101831 but using a custom class.
```
template<int s>
struct a
{
constexpr int size() const { return s; }
int data[s];
};
int f()
{
a<10> b;
return b.size();
}
```
I am not even sure we want to warn on the usage from size method at all.
Maybe we can special case it based on the method name of size instead of the
change that was done for PR 101831.
begin (PR 116697) and end also seems like good candidates too.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116697
[Bug 116697] Bogus -Wuninitialized warning when no access to uninitialized data
is done