This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Different behavior of g++ and gcc (both egcs) compilers
- To: Alex Vinokur <alexander dot vinokur at telrad dot co dot il>
- Subject: Re: Different behavior of g++ and gcc (both egcs) compilers
- From: Mumit Khan <khan at xraylith dot wisc dot EDU>
- Date: Wed, 14 Jul 1999 09:15:00 -0500
- cc: EGCS_BUGS <egcs-bugs at egcs dot cygnus dot com>
Alex Vinokur <alexander.vinokur@telrad.co.il> writes:
> Hi,
>
> Here is a simple program.
> Why is the g++ and gcc (both egcs) compilers' behavior different?
>
> Thanks in advance,
> Alex
>
>
>
> //#########################################################
> //------------------- C++ code : BEGIN -------------------
> // main.C
>
> int n = 0;
> void foo (char a [n])
> { // Line#3
> }
>
> int main()
> {
> return 0;
> }
>
>
> //------------------- C++ code : END ----------------------
>
> //#########################################################
> //------------------- Compilation Results : BEGIN ---------
>
> %g++ main.c
> main.c:3: variable-size type declared outside of any function
>
> %gcc main.c // OK
>
When you compile .c file with gcc driver, it's compiled as C; when
you compile .c file with g++ driver, it's compiled as C++. Now
compile with -ansi -pedantic (to disable GCC extensions), look at
the messages from gcc/g++ and then see if it makes sense to you.
It's not a bug in the compiler.
Regards,
Mumit