egcs-19980418 Internal compiler error

Jeffrey A Law law@cygnus.com
Sun Jun 28 01:38:00 GMT 1998


  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



More information about the Gcc-bugs mailing list