From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14121 invoked by alias); 13 Oct 2002 20:26:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 14101 invoked by uid 71); 13 Oct 2002 20:26:00 -0000 Resent-Date: 13 Oct 2002 20:26:00 -0000 Resent-Message-ID: <20021013202600.14100.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, yoavhirsch@yahoo.com Received: (qmail 8045 invoked by uid 61); 13 Oct 2002 20:17:41 -0000 Message-Id: <20021013201741.8044.qmail@sources.redhat.com> Date: Sun, 13 Oct 2002 13:26:00 -0000 From: yoavhirsch@yahoo.com Reply-To: yoavhirsch@yahoo.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/8214: GCC does not enforce the left-most "const" in a "const char * const" declaration. X-SW-Source: 2002-10/txt/msg00531.txt.bz2 List-Id: >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 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 int main() { const char * source = "source"; const char * target = "target"; std::strcpy(target,source); return 0; } >Release-Note: >Audit-Trail: >Unformatted: