From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#40671: [DOC] modify literal objects Date: Sun, 26 Apr 2020 17:19:28 +0300 Message-ID: <83zhay5nyn.fsf@gnu.org> References: <83tv1finob.fsf@gnu.org> <1E9E4C19-37C2-4E24-91B7-8101F9CFBF35@acm.org> <527dc4b5-3176-38b5-f2c1-1483ffc814a1@cs.ucla.edu> <87k12b6sv2.fsf@web.de> <2225099d-16e1-645d-0342-a054da53363f@cs.ucla.edu> <87a7376nv9.fsf@web.de> <99d7a8f9-7732-e1e3-414e-aabbea4433ac@cs.ucla.edu> <87o8rnasfk.fsf@web.de> <9e6c138d-cb9f-6075-34df-a8d1d931343b@cs.ucla.edu> <871rofxbz9.fsf@web.de> <93463227-33a8-85a0-fd19-8b29b75997f3@yandex.ru> <969b3497-0afd-d104-6792-d744d31548fa@cs.ucla.edu> <2935ec84-bdea-2e20-01b9-8ed08cc61c6c@yandex.ru> <669981e5-f601-5c18-1a8b-ee316ad001ec@cs.ucla.edu> <4b8b7e98-029e-58ac-59ff-6cd984b7eb85@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="46922"; mail-complaints-to="usenet@ciao.gmane.io" Cc: ke.vigouroux@laposte.net, eggert@cs.ucla.edu, 40671@debbugs.gnu.org, michael_heerdegen@web.de, mattiase@acm.org, rms@gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 26 16:20:43 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jSi9A-000C3k-1J for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Apr 2020 16:20:40 +0200 Original-Received: from localhost ([::1]:60236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSi99-0000tD-2l for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Apr 2020 10:20:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56090) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSi8j-0000Y9-L0 for bug-gnu-emacs@gnu.org; Sun, 26 Apr 2020 10:20:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jSi8Z-00059Q-2x for bug-gnu-emacs@gnu.org; Sun, 26 Apr 2020 10:20:13 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50550) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jSi8Y-000585-N9 for bug-gnu-emacs@gnu.org; Sun, 26 Apr 2020 10:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jSi8Y-0007B2-Hg for bug-gnu-emacs@gnu.org; Sun, 26 Apr 2020 10:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Apr 2020 14:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40671 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 40671-submit@debbugs.gnu.org id=B40671.158791080127577 (code B ref 40671); Sun, 26 Apr 2020 14:20:02 +0000 Original-Received: (at 40671) by debbugs.gnu.org; 26 Apr 2020 14:20:01 +0000 Original-Received: from localhost ([127.0.0.1]:33863 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jSi8Q-0007Ac-Qg for submit@debbugs.gnu.org; Sun, 26 Apr 2020 10:20:01 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52984) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jSi8M-0007AO-MS for 40671@debbugs.gnu.org; Sun, 26 Apr 2020 10:19:54 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:43728) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSi8F-0004cc-K3; Sun, 26 Apr 2020 10:19:43 -0400 Original-Received: from [176.228.60.248] (port=4559 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jSi88-0004SO-IH; Sun, 26 Apr 2020 10:19:37 -0400 In-Reply-To: (message from Dmitry Gutov on Sun, 26 Apr 2020 17:03:38 +0300) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:179067 Archived-At: > From: Dmitry Gutov > Date: Sun, 26 Apr 2020 17:03:38 +0300 > Cc: Michael Heerdegen , ke.vigouroux@laposte.net, > 40671@debbugs.gnu.org > > > #include > > int main (void) { return !strcpy ("a", "b"); } > > > > This function attempts to modify the "a" string constant, so it might dump core, > > or might return 0, or might do other things. > > g++ string_const.c++ > string_const.c++: In function ‘int main()’: > string_const.c++:2:35: warning: ISO C++ forbids converting a string > constant to ‘char*’ [-Wwrite-strings] > 2 | int main (void) { return !strcpy ("a", "b"); } Did you try compiling that as a C program, not a C++ program? If I force the C compiler to use -Wwrite-strings, then I get: gcc -Wwrite-strings string_const.c string_const.c: In function 'main': string_const.c:2:35: warning: passing argument 1 of 'strcpy' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] int main (void) { return !strcpy ("a", "b"); } ^~~ In file included from string_const.c:1:0: d:\usr\include\string.h:79:40: note: expected 'char *' but argument is of type 'const char *' _CRTIMP __cdecl __MINGW_NOTHROW char *strcpy (char *, const char *); ^~~~~~ but even that goes away if I modify the program as follows: #include int main (void) { return !strcpy ((char *)"a", "b"); }