[gafton@redhat.com: Re: C++ question]

Mark Mitchell mark@markmitchell.com
Thu Oct 29 01:44:00 GMT 1998


  > Mark's got more than a clue.  If he says it's no good, I'd tend to
  > believe him. 

Thanks, Jeff, but I was only half right in this case...

  Well, the "problem" is that is a lot of C++ code out there that are
  calling some functions prototyped as:
	  int foo(char *);
  Making a call to those functions like foo("static string") is more than
  common.

As Jason points out, that usage is explicitly endorsed by the
standard, and not bogus as I had claimed.  The standard has a special
exception to allow the usage you mention (e.g., `foo("abc")'), but
this exception is deprecated.  There's nothing about the other case
you mention `foo(x ? "abc" : "def")'; I still believe this case is
indeed illegal.

Jason suggested that we might go back to allowing const-incorrect
calls to allow this case.  I don't think so.  That's just asking for
trouble: when a program crashes because of some assignment to a const
object that wasn't supposed to happen, nobody will thank us for
presenting them with this hard-to-track-down non-standard situation.

On the other hand, we might look at trying to allow a few more
non-standard conversions involving strings.  I note that the EDG
front-end does allow the `?:' case, for example.

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com



More information about the Gcc-bugs mailing list