RE: Need suggestion for using right gcc 8.2 warning flag

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

 



Thank you.

-----Original Message-----
From: Jonathan Wakely <jwakely.gcc@xxxxxxxxx>
Sent: Thursday, April 1, 2021 1:57 PM
To: Kannuswamy, Nanthakumar <nanthakumar.kannuswamy@xxxxxxxxxx>
Cc: gcc-help@xxxxxxxxxxx
Subject: Re: Need suggestion for using right gcc 8.2 warning flag

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.



This communication is the property of E*TRADE Financial Holdings, LLC and its affiliates and does not constitute an offer to sell or the solicitation of an offer to buy any security. It is intended only for the person to whom it is addressed and may contain information that is privileged, confidential, or otherwise protected from disclosure. Distribution or copying of this communication, or the information contained herein, by anyone other than the intended recipient is prohibited. If you have received this communication in error, please immediately notify E*TRADE Financial Holdings, LLC at (800) 387-2331, and delete and destroy any copies hereof.





[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