This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/8586: Compiler should warn when converting a string literal to char*
- From: austern at apple dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 14 Nov 2002 22:27:05 -0000
- Subject: c++/8586: Compiler should warn when converting a string literal to char*
- Reply-to: austern at apple dot com
>Number: 8586
>Category: c++
>Synopsis: Compiler should warn when converting a string literal to char*
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Nov 14 14:36:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Matt Austern
>Release: unknown-1.0
>Organization:
>Environment:
>Description:
In C++, a string literal is of type const char[N]. However, there is a special conversion, just for string literals, that lets you assign a string literal to char*.
This conversion is known to be unsafe, it was put in to support legacy code that isn't const-correct, and it is deprecated. The compiler should issue a warning when it applies that conversion. The only issue is whether that warning should be on or off by default.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: