This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: egcs-19980418 Internal compiler error
- To: Kamil Iskra <iskra at student dot uci dot agh dot edu dot pl>
- Subject: Re: egcs-19980418 Internal compiler error
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Sun, 28 Jun 1998 02:16:27 -0600
- cc: Jorg Pietschmann <pietsch at swissline dot ch>, egcs-bugs <egcs-bugs at cygnus dot com>
- Reply-To: law at cygnus dot com
In message <Pine.LNX.3.96.980502141605.581E-100000@jinks.home>you write:
> This is the same problem that I reported a few days ago.
>
> > void openpty()
> > {
> > char * const line = "foo";
> > line[1] = 'a';
> > }
> >
> > The code is somewhat suspect, i believe string constants are read-only
> > on solaris by default.
>
> You are right, the code is incorrect.
>
> An optimisation that EGCS attempts to perform (basically, substituting a
> memory reference to read-only string by the actual value of the character)
> assumes a correct code (i.e., one that attempts to READ the value). EGCS
> gets confused when it finds an attempt to write to the location, and hence
> the abort.
>
> A simple workaround is to remove the "const" qualifier from the pointer.
> This doesn't remove the undefined behavior, though. A better patch would
> be to declare "line" as an array of char.
>
> > I have yet to test this with the actual release (it is still compiling
> > itself :-/)
>
> The bug is in there since Oct 26, 1997, IIRC. EGCS 1.0.x is affected.
Just in case nobody told you -- this bug was fixed back in early May.
jeff