https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103827

--- Comment #4 from Jan Hubicka <hubicka at ucw dot cz> ---
> That would be undefined, because s is defined const and so doing const_cast 
> and
> then modifying it is undefined behaviour. However, this would be fine:
Cool, then I will look into getting modref and PTA to understand it.
What about escape bits? Is it OK to save the address to global memory
and then check it in the destructor?
I suppose it makes no sense to return a pointer since it will be
available only after end of lifetime?
> 
> #include <string>
> int foo (const std::string s);
> 
> int foo (std::string s)
> {
>    s = "I am long string over 15 chars";
>    return s.size();
> }
> 
> The const in the first declaration of foo is meaningless, it doesn't mean it 
> is
> necessarily const in the function definition.
OK, what about having const reference?  const std::string &s?

Reply via email to