[llvm-bugs] [Bug 50735] Missing optimization for member function with const attribute

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 17 18:46:15 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50735

Allen zhong <zhongyunde at tom.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|REOPENED                    |RESOLVED

--- Comment #4 from Allen zhong <zhongyunde at tom.com> ---
thanks, you are right, I verify with following change as you show, it indeed
can modify 'bins[0]'


class NPair /*: protected Pointers */ {
public:
  int bins[10];
  //int exclusion(int n) __attribute__((const));
  int exclusion (int n) const {
        printf ("before %d\n", bins[0]);
    NPair* pt = const_cast<NPair*>(this);
    pt->bins[0] = 1;
        printf ("after %d\n", bins[0]);
  }
  NPair (void) {
     bins[0] = 3;
  }
};

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210618/ab9302d2/attachment-0001.html>


More information about the llvm-bugs mailing list