This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/5546: Bad "const" verification



>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]