|
From: | Dmitry Gutov |
Subject: | bug#40671: [DOC] modify literal objects |
Date: | Sun, 26 Apr 2020 17:34:56 +0300 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
On 26.04.2020 17:19, Eli Zaretskii wrote:
Did you try compiling that as a C program, not a C++ program?
As C++.From what I understand, in C string literals are not "const", it's just UB to modify them.
but even that goes away if I modify the program as follows: #include <string.h> int main (void) { return !strcpy ((char *)"a", "b"); }
If you go out of your way to avoid warnings, then indeed, the compiler won't show them.
And typecasts are an easy way to turn compilation errors into runtime errors, in general.
[Prev in Thread] | Current Thread | [Next in Thread] |