https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113687

            Bug ID: 113687
           Summary: -Warray-bounds is not emitted inside class method
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nmmm at nmmm dot nu
  Target Milestone: ---

No warning -Warray-bounds is shown when code is inside class method, defined
inside the class body or outside if they are inline or constexpr.

struct S{
    int p(){
        int x[2] = {0, 0};

        return x[3]; // no warning shown
    }

    static int ps(){
        int x[2] = {0, 0};

        return x[3]; // no warning shown
    }

    int ps2inl();
    int ps2();
};

inline int S::ps2inl(){
    int x[2] = {0, 0};

    return x[3]; // no warning shown
}

int S::ps2(){
    int x[2] = {0, 0};

    return x[3]; // warning shown correctly
}

int f(){
    int x[2] = {0, 0};

    return x[3]; // warning shown correctly
}

int main(){
}

Reply via email to