This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC 4.1.2: Character array initialization issue


On 02/03/2010 06:00 AM, Ian Lance Taylor wrote:
> "Vardhan, Sundara (GE Infra, Energy)" <sundara.vardhan@ge.com> writes:
> 
>> I am using GCC 4.1.2 in Linux 5.4 RHEL. I see the following issue. Any
>> pointers or advice will be greatly appreciated.
>>
>> typedef char big_at[1000000];
>> int main()
>> {
>> char    big_a[1000000] = "";
>> big_at  big_b = "";
>> return(0);
>> }
>>
>> The result is:
>>
>>> cc *.c; ls -l
>> -rwxrwxr-x 1 bondcl xa 1006752 Feb  2 10:13 a.out
>> -rw-rw-r-- 1 bondcl xa     104 Feb  2 10:13 test.c
>>
>> Note the size of the resulting a.out file. An alternate:
>>
>> typedef char big_at[1000000];
>> int main()
>> {
>> char    big_a[1000000] = {'\0'};
>> big_at  big_b = {'\0'};
>> return(0);
>> }
>>
>> Results in:
>>
>>> cc *.c; ls -l
>> -rwxrwxr-x 1 bondcl xa 6736 Feb  2 10:09 a.out
>> -rw-rw-r-- 1 bondcl xa  112 Feb  2 10:09 test.c
>>
>> Why is the difference in the size of the a.out file. Am I missing any
>> compiler option?
> 
> That looks like a bug.  I can recreate the problem with gcc 4.2.4, but
> it appears to be fixed in the current development sources.

I agree.  Also, I suspect it's only a bug at -O0.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]