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

            Bug ID: 38068
           Summary: warning: Attempt to free released memory that can't be
                    freed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: dcough...@apple.com
          Reporter: vcato1...@yahoo.com
                CC: llvm-bugs@lists.llvm.org

The following code produces a warning 

class test {
  public:
    test()
    : allocated(new int),
      x(1)
    {
    }

    ~test()
    {
      if (x==0) {
        delete allocated;
      }
    }

    test f() const
    {
      test t1(*this);
      {
        test t2(*this);
      }
      return t1;
    }

  private:
    int *allocated;
    const int x;
};


<source>:12:9: warning: Attempt to free released memory

        delete allocated;

The analyzer believes that the memory will be released twice even though it can
 never be released even once.  The analyzer doesn't seem to recognize that a
const member that can only be initialized to 1 can never be 0.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to