Re: Need suggestion for using right gcc 8.2 warning flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 1 Apr 2021 at 18:25, Kannuswamy, Nanthakumar wrote:
>
> Thanks
>
> We started working on fixing the code.
>
> How its behaving differently in gcc 4.2 and gcc 8.2 compiler?

In GCC 4.x the std::string class uses a reference-counted
implementation, so the pointer returns by getName().c_str() is the
same pointer returned by name.c_str(), so it happens to still be valid
after the getName1() function returns.

Since GCC 5.x the default is to use a non-reference-counted
std::string implementation, so the pointer returned by
getName().c_str() becomes invalid when temporary returned by getName()
is destroyed.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux