This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Bug with assignment to const * in C (but not in C++)
- To: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Subject: Re: Bug with assignment to const * in C (but not in C++)
- From: "John C. Ruttenberg" <rutt at tensilica dot com>
- Date: Tue, 2 Feb 1999 12:35:17 -0500 (EST)
- Cc: egcs-bugs at cygnus dot com
- References: <199902011950.OAA25977@gertie.ma.tensilica.com><orn22x964h.fsf@araguaia.dcc.unicamp.br>
- Reply-to: rutt at tensilica dot com
Alexandre Oliva:
> On Feb 1, 1999, John Ruttenberg <rutt@tensilica.com> wrote:
>
> > This compiles without warning by g++ but gcc warns:
>
> > y.c: In function `x':
> > y.c:7: warning: assignment from incompatible pointer type
>
> > I thought that assignment to greater constness was always allowed.
>
> Not always, see http://reality.sgi.com/austern/std-c++/faq.html#C1
>
> > Are the rules different for ANSI C then for C++?
>
> I'm no C language lawyer, but the code looks like valid C++ for me.
I don't get it. Matt's web page seems to say this is incorrect. Yet g++
accepts it. Is this a bug with g++, then? gcc does warn. So perhaps it is
correct?