Re: A simple query about memory mgmt

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

 



"Manish Katiyar" <mkatiyar@xxxxxxxxx> writes:

> On Wed, Aug 13, 2008 at 10:07 AM, Rene Herman <rene.herman@xxxxxxxxxxxx> wrote:
>> On 13-08-08 02:57, Peter Teoh wrote:
>>
>>> But since u have assigned it to the same address of NAME, it will always
>>> print HELLO world.   So the whole thing has nothing got to do with
>>> optimization (gcc -O0 to disable it, which is also default).
>>
>> Can y'all please just listen to Johannes? It definitely does. We have:
>>
>>> int main()
>>> {
>>>    char *p_name = "santosh";
>>>    char *q_name = "santosh";
>>
>> It is unspecified whether or not the compiler will allocate one or two
>> copies of the character sequence "santosh" and therefore whether or not
>> p_name != q_name;
>
> Refer to below link ...... first bullet clearly says that gcc will
> store only one copy if strings are identical.
>
> http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Incompatibilities.html

gcc is one compiler out of many.  While gcc might always collapse them,
others might not always or never at all do so.

	Hannes

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux