[llvm-commits] [llvm] r70790 - /llvm/trunk/docs/LangRef.html

Eli Friedman eli.friedman at gmail.com
Mon May 4 10:35:20 PDT 2009


On Mon, May 4, 2009 at 9:38 AM, Chris Lattner <clattner at apple.com> wrote:
>
> On May 4, 2009, at 1:49 AM, Török Edwin wrote:
>
>> Also what happens with C++'s const member functions?
>> If there are mutable class members they aren't technically readonly,
>> since they have the side-effect of modifying the object.
>> However most people use this as a 'logical' const, i.e. the object may
>> be modified, but the new object is equivalent to the old one.
>> Can this be modeled via an LLVM attribute?
>
> No, this cannot be modeled, because const is allowed to be cast away.

Well, not quite... per [dcl.type.cv], "Except that any class member
declared mutable (7.1.1) can be modified, any attempt to modify a
const object during its lifetime (3.8) results in undefined behavior."
 That's a pretty narrow exception, though, and C++ programs generally
aren't written to take advantage of it.

-Eli




More information about the llvm-commits mailing list