This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/2988: Incorrect error on assignment of const char[] to char *
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/2988: Incorrect error on assignment of const char[] to char *
- From: ros at tao-group dot com
- Date: 29 May 2001 12:15:14 -0000
- Reply-To: ros at tao-group dot com
>Number: 2988
>Category: c++
>Synopsis: Incorrect error on assignment of const char[] to char *
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Tue May 29 05:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: ros@tao-group.com
>Release: gcc version 2.95.2 20000220 (Debian GNU/Linux)
>Organization:
>Environment:
Debian GNU/Linux 2.2
>Description:
>From C++ Programming Language 3rd Ed 5.2.2:
The type of a string literal is ... const char[n];
A string literal can be assigned to char *
The compiler fails to allow this in conditional expressions.
(Verified still a problem using codesourcery with build
2001-05-28.)
>How-To-Repeat:
compile attached; default options suffice. Observe message
assignment to `char *' from `const char *' discards qualifiers
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="ros2.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="ros2.cc"
aW50Cm1haW4gKGludCBhcmdjLCBjaGFyICoqYXJndikKewogIGNoYXIgKmFyZ3NbNF07CiAgaW50
IGZsYWdzOwoKICAvLyB0aGlzIGZhaWxzCgogIGFyZ3NbMV0gPSAoZmxhZ3M9PTApID8gKGNoYXIg
KikiLW4iIDogKGNoYXIgKikiLXAiOwoKICAvLyB0aGlzIGVxdWl2YWxlbnQgY29kZSB3b3Jrcwog
CiAgaWYgKGZsYWdzPT0wKSAKICAgIGFyZ3NbMV0gPSAiLW4iOwogIGVsc2UKICAgIGFyZ3NbMV0g
PSAiLXAiOwoKICByZXR1cm4gMDsKfQo=