public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: yoavhirsch@yahoo.com To: gcc-gnats@gcc.gnu.org Subject: c++/8214: GCC does not enforce the left-most "const" in a "const char * const" declaration. Date: Sun, 13 Oct 2002 13:26:00 -0000 [thread overview] Message-ID: <20021013201741.8044.qmail@sources.redhat.com> (raw) >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:
reply other threads:[~2002-10-13 20:26 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20021013201741.8044.qmail@sources.redhat.com \ --to=yoavhirsch@yahoo.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).