First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 8214
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Mark Mitchell <mmitchel@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: yoavhirsch@yahoo.com
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 8214 depends on: Show dependency tree
Show dependency graph
Bug 8214 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2002-10-13 13:26
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.

Release:
gcc version 3.2

Environment:
Linux metropolis 2.4.18-3 #1 Thu Apr 18 07:37:53 EDT 2002 i686 unknown

How-To-Repeat:
#include <string>
int main()
{
  const char *       source = "source";
  const char * const target = "target";
  std::strcpy(target,source);
  return 0;
}

------- Comment #1 From yoavhirsch@yahoo.com 2002-10-13 13:26 -------
Fix:
http://gcc.gnu.org/ml/gcc-patches/2002-11/msg01979.html

------- Comment #2 From Wolfgang Bangerth 2002-11-22 11:36 -------
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. This used to give an error with 2.95, but does
    no more. It is thus a regression. The code in question is
    -------------------------
    void foo(char *dest);
    
    int main() {
      const char * const p = "abc";
      foo (p);
    }
    ------------------------------
    The thing is weird, because if p is not initialized by 
    "abc" but with a null pointer, then gcc correctly gives
    an error...
    
    tmp/g> /home/bangerth/bin/gcc-3.3y-pre/bin/c++ -c x.cc
    tmp/g> /home/bangerth/bin/gcc-3.2.1-pre/bin/c++ -c x.cc
    tmp/g> c++ -c x.cc
    x.cc: In function `int main()':
    x.cc:5: passing `const char *const' as argument 1 of `foo(char *)' discards qualifiers

------- Comment #3 From Mark Mitchell 2002-11-30 13:48 -------
Responsible-Changed-From-To: unassigned->mmitchel
Responsible-Changed-Why: Working on a fix.

------- Comment #4 From Mark Mitchell 2002-11-30 20:01 -------
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed in G++ 3.3.

------- Comment #5 From Mark Mitchell 2002-12-01 02:11 -------
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8214
Date: 1 Dec 2002 02:11:06 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2002-11-30 18:11:06
 
 Modified files:
 	gcc/testsuite  : ChangeLog 
 	gcc/cp         : ChangeLog typeck.c 
 Added files:
 	gcc/testsuite/g++.dg/init: string1.C 
 
 Log message:
 	PR c++/8214
 	* g++.dg/init/string1.C: New test.
 	
 	PR c++/8214
 	* typeck.c (convert_for_assignment): Do not use
 	decl_constant_value on the operand.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2240&r2=1.2241
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/string1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3058&r2=1.3059
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.434&r2=1.435
 


------- Comment #6 From Mark Mitchell 2002-12-01 02:11 -------
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8214
Date: 1 Dec 2002 02:11:06 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2002-11-30 18:11:06
 
 Modified files:
 	gcc/testsuite  : ChangeLog 
 	gcc/cp         : ChangeLog typeck.c 
 Added files:
 	gcc/testsuite/g++.dg/init: string1.C 
 
 Log message:
 	PR c++/8214
 	* g++.dg/init/string1.C: New test.
 	
 	PR c++/8214
 	* typeck.c (convert_for_assignment): Do not use
 	decl_constant_value on the operand.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2240&r2=1.2241
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/string1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3058&r2=1.3059
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.434&r2=1.435
 

------- Comment #7 From Mark Mitchell 2002-12-01 03:58 -------
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8214
Date: 1 Dec 2002 03:58:53 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	mmitchel@gcc.gnu.org	2002-11-30 19:58:53
 
 Modified files:
 	gcc/testsuite  : ChangeLog 
 	gcc/cp         : ChangeLog typeck.c 
 Added files:
 	gcc/testsuite/g++.dg/init: string1.C 
 
 Log message:
 	PR c++/8214
 	* g++.dg/init/string1.C: New test.
 	
 	PR c++/8214
 	* typeck.c (convert_for_assignment): Do not use
 	decl_constant_value on the operand.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.59&r2=1.1672.2.166.2.60
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/string1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.2685.2.114.2.44&r2=1.2685.2.114.2.45
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.388.2.10.2.2&r2=1.388.2.10.2.3
 


------- Comment #8 From Mark Mitchell 2002-12-01 03:58 -------
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8214
Date: 1 Dec 2002 03:58:53 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	mmitchel@gcc.gnu.org	2002-11-30 19:58:53
 
 Modified files:
 	gcc/testsuite  : ChangeLog 
 	gcc/cp         : ChangeLog typeck.c 
 Added files:
 	gcc/testsuite/g++.dg/init: string1.C 
 
 Log message:
 	PR c++/8214
 	* g++.dg/init/string1.C: New test.
 	
 	PR c++/8214
 	* typeck.c (convert_for_assignment): Do not use
 	decl_constant_value on the operand.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.59&r2=1.1672.2.166.2.60
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/string1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.2685.2.114.2.44&r2=1.2685.2.114.2.45
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.388.2.10.2.2&r2=1.388.2.10.2.3

First Last Prev Next    No search results available      Search page      Enter new bug