[LLVMbugs] [Bug 9119] New: no error calling non-const method on const object

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 1 13:03:29 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=9119

           Summary: no error calling non-const method on const object
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Testcase:

  struct Struct {
   void Func() {}
  };

  int main() {
   const Struct s = {};
   void (Struct::*func_ptr)() = &Struct::Func;
   (s.*func_ptr)();
   return 0;
  }

's' is const, then we call a non-const method on it. Clang emits no error, GCC
and Comeau do. Here's GCC:

b3410310.cc: In function ‘int main()’:
b3410310.cc:8: error: invalid conversion from ‘const Struct*’ to ‘Struct*’

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list