This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: An Ansi-C question or... Is egcs/gcc Ansi compliant?
- To: esoft at arrakis dot es (Enrique I.R.)
- Subject: Re: An Ansi-C question or... Is egcs/gcc Ansi compliant?
- From: Joe Buck <jbuck at Synopsys dot COM>
- Date: Wed, 30 Dec 98 19:37:00 PST
- Cc: egcs at cygnus dot com
> Just playing with const:
>
> const int i=3D0;
> i++;
> printf("%i\n",i);
>
> You get a warning only (increment of read-only variable) and then both =
> compiles
> (egcs&gcc) and 'i' is modified at runtime. I was perplexed and checked =
> this with
> other compilers (OSF's, vc++, bcb) and couldn't even compile this.
egcs is technically correct, in that all that the ANSI/ISO standard
requires is a diagnostic here, and a warning qualifies as a diagnostic.
However, I agree with you that const violations of this kind should
be errors, not warnings ... especially if egcs then goes on to put i
in a read-only section and the program crashes at runtime!
> Why ignore egcs/gcc the const keyword such way?
The keyword is not ignored, you get a warning.
> Is there anyway to get a real const with egcs?
It's a real const.