public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: weigelt@metux.de, gcc-help@gcc.gnu.org
Subject: Re: Optimizing
Date: Sun, 30 Jan 2011 21:02:00 -0000	[thread overview]
Message-ID: <AANLkTi=dUr5nUGBBxzHUz=+z6Z=Fn3bxGhfj8pd30+F1@mail.gmail.com> (raw)
In-Reply-To: <20110130204022.GF29226@nibiru.local>

On 30 January 2011 20:40, Enrico Weigelt wrote:
> * Kalle Olavi Niemitalo <kon@iki.fi> wrote:
>
>> Although the second parameter is const void *, the language still
>> allows the function to modify the object to which that points,
>> provided that the object was not defined as const.
>
> Doesn't that defeat the whole purpose of const ?

No. http://www.gotw.ca/gotw/081.htm


> BTW: let me add another question:
>
>
>    const std::string str;
>
>    void one(const std::string s)
>    {
>        str = s;
>    }
>
>    void two(const char* s)
>    {
>        one(s);
>    }
>
>    void three()
>    {
>        two("hello world");
>    }
>
>
> What actually happens here under the hood ? Is this reliable ?
> (lifetime of the string object)

It won't compile because you assign to a const, so I don't understand
the question.

      reply	other threads:[~2011-01-30 21:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-30 20:18 Optimizing Magnus Fromreide
2011-01-30 20:24 ` Optimizing Kalle Olavi Niemitalo
2011-01-30 20:55   ` Optimizing Enrico Weigelt
2011-01-30 21:02     ` Jonathan Wakely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTi=dUr5nUGBBxzHUz=+z6Z=Fn3bxGhfj8pd30+F1@mail.gmail.com' \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=weigelt@metux.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).