c++/8586: Compiler should warn when converting a string literal to char*

austern@apple.com austern@apple.com
Thu Nov 21 04:06:00 GMT 2002


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



More information about the Gcc-prs mailing list