[cfe-dev] More extensive unused variable checks
Daniel B Mosesson
dmosess1 at binghamton.edu
Tue Apr 16 19:26:26 PDT 2013
Thread-safe is nice, but it does not mean that the function has no
side effects (which is the point here).
There is nothing that stops a const function from using mutexes to
ensure synchronous I/O for example.
I have seen the talk that you mention (I belive its
but I am not sure it is relavant to the topic at hand (though I agree
with its appeal).
On Tue, Apr 16, 2013 at 8:09 PM, Sean Silva <silvas at purdue.edu> wrote:
> On Tue, Apr 16, 2013 at 7:45 PM, David Blaikie <dblaikie at gmail.com> wrote:
>> On Tue, Apr 16, 2013 at 4:27 PM, Sean Silva <silvas at purdue.edu> wrote:
>> > On Tue, Apr 16, 2013 at 2:32 PM, Daniel B Mosesson
>> > <dmosess1 at binghamton.edu>
>> > wrote:
>> >> Not really. Const does not enforce no I/O and no modification of
>> >> pointer targets.
>> > For types used in conjunction with the standard library, C++11 actually
>> > puts
>> > pretty stringent requirements on what a const function can do. Basically
>> > any
>> > function marked const that is used in conjunction with the standard
>> > library
>> > must be thread-safe (or else you get undefined behavior).
>> I've heard about Herb Sutter talking about this, but I didn't/don't
>> think it's actually enshrined in the standard, is it?
> He quotes standard language in that talk. Also, I pretty much trust what
> Herb Sutter has to say about these things.
> Besides, I like the "thread-safe const/mutable" semantics, so I am biased
> towards being willing to believe it ;)
> -- Sean Silva
More information about the cfe-dev