public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/8214: GCC does not enforce the left-most "const" in a  "const char * const"  declaration.
@ 2002-10-13 13:26 yoavhirsch
  0 siblings, 0 replies; only message in thread
From: yoavhirsch @ 2002-10-13 13:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         8214
>Category:       c++
>Synopsis:       GCC does not enforce the left-most "const" in a  "const char * const"  declaration.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 13 13:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Yoav Hirsch
>Release:        gcc version 3.2
>Organization:
>Environment:
Linux metropolis 2.4.18-3 #1 Thu Apr 18 07:37:53 EDT 2002 i686 unknown
>Description:
GCC correctly gives an error when trying to strcpy into a "const char *" pointer.  But GCC incorrectly allows a strcpy into a "const char * const" pointer as shown in the code below.
>How-To-Repeat:
#include <string>
int main()
{
  const char *       source = "source";
  const char * const target = "target";
  std::strcpy(target,source);
  return 0;
}
>Fix:
//make the target pointer non-const:
#include <string>
int main()
{
  const char *       source = "source";
  const char *       target = "target";
  std::strcpy(target,source);
  return 0;
}
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-13 20:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-13 13:26 c++/8214: GCC does not enforce the left-most "const" in a "const char * const" declaration yoavhirsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).