This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/5546: Bad "const" verification
- From: jbach1 at caramail dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 30 Jan 2002 23:21:40 -0000
- Subject: c++/5546: Bad "const" verification
- Reply-to: jbach1 at caramail dot com
>Number: 5546
>Category: c++
>Synopsis: Bad "const" verification
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: unassigned
>State: open
>Class: accepts-illegal
>Submitter-Id: net
>Arrival-Date: Wed Jan 30 15:26:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Pierre Chatelier
>Release: gcc 3.0.3
>Organization:
>Environment:
DOS (DJGPP)
>Description:
A const string (type char*, not string from <string>) can
be overwritten by strcpy
>How-To-Repeat:
#include <cstring>
#include <iostream>
using namespace std;
int main(int, char* [])
{
cout << "Hello" << endl;
strcpy("Hello", "World");
cout << "Hello" << endl;
return 0;
}
compiled with `gxx -Wall -ansi -pedantic`
no warnings appear during compilation
the result on screen is
Hello
World
Terrific, isn't it ?
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: