From -3204969733220525007
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,9d8a465d14c25851,start
X-Google-Attributes: gidf78e5,public
From: Mark Jones <mark@booksys.com>
Subject: strchr should be fixed in the standard
Date: 1997/05/06
Message-ID: <336F6A69.2DD8@booksys.com>#1/1
X-Deja-AN: 239911845
X-Original-Date: Tue, 06 May 1997 12:29:13 -0500
Organization: Book Systems, Inc.
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBM2+NfUy4NqrwXLNJAQFC4QIAzSCc3M6gIBOfmqsmiZmn8bWkawoy3e63 JMwOl8CdAsSIDqiJV1aB6NuZIHZWjFKyz3YyLJro9Pe7iPL00Irc0w== =OOjP
Reply-To: mark@booksys.com
Newsgroups: comp.std.c++
Originator: austern@isolde.mti.sgi.com


myfunc(const char *s)
{
	char *d = strchr(s, 'c');

	.
	.
	.

	*d = 0;			// violates the  const char * protection
}

The above code is subtle and should be flagged by the compiler.  But
won't be because of the way that strchr is declared.


Has anyone given thought to having two version of strchr?


const char *strchr(const char *s, int c)
and
char *strchr(char *s, int c)

This is one that could not be fixed in C because there is no
overloading.  However this one could be fixed in C++

Comments?  Is this old news?
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]



