Re: GCC 4.1.2: Character array initialization issue

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

 



"Vardhan, Sundara (GE Infra, Energy)" <sundara.vardhan@xxxxxx> 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.

Ian

[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