[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#40671: [DOC] modify literal objects
From: |
Paul Eggert |
Subject: |
bug#40671: [DOC] modify literal objects |
Date: |
Sat, 25 Apr 2020 20:49:27 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
On 4/25/20 12:30 PM, Dmitry Gutov wrote:
> On 25.04.2020 06:20, Paul Eggert wrote:
>>> When a value is constant in C or C++, you can't change it.
>> Yes, you can't change it in a portable program, because if you attempt to
>> change
>> it the resulting behavior is undefined. The attempt might succeed so that the
>> "constant" is changed, or you might get a core dump, or you might get an
>> exception, or something else might happen.
>
> Might succeed? Will it even compile?
Yes, although the C/C++ program must type-check and satisfy all other static
constraints of course (otherwise it won't compile). Here's a simple example:
#include <string.h>
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.
- bug#40671: [DOC] modify literal objects, (continued)
- bug#40671: [DOC] modify literal objects, Mattias EngdegÄrd, 2020/04/24
- bug#40671: [DOC] modify literal objects, Dmitry Gutov, 2020/04/24
- bug#40671: [DOC] modify literal objects, Paul Eggert, 2020/04/24
- bug#40671: [DOC] modify literal objects, Dmitry Gutov, 2020/04/24
- bug#40671: [DOC] modify literal objects, Paul Eggert, 2020/04/24
- bug#40671: [DOC] modify literal objects, Dmitry Gutov, 2020/04/25
- bug#40671: [DOC] modify literal objects,
Paul Eggert <=
- bug#40671: [DOC] modify literal objects, Dmitry Gutov, 2020/04/26
- bug#40671: [DOC] modify literal objects, Eli Zaretskii, 2020/04/26
- bug#40671: [DOC] modify literal objects, Dmitry Gutov, 2020/04/26
- bug#40671: [DOC] modify literal objects, Eli Zaretskii, 2020/04/26
- bug#40671: [DOC] modify literal objects, Dmitry Gutov, 2020/04/26
- bug#40671: [DOC] modify literal objects, Eli Zaretskii, 2020/04/26
- bug#40671: [DOC] modify literal objects, Dmitry Gutov, 2020/04/26
- bug#40671: [DOC] modify literal objects, Eli Zaretskii, 2020/04/26
- bug#40671: [DOC] modify literal objects, Dmitry Gutov, 2020/04/26
- bug#40671: [DOC] modify literal objects, Eli Zaretskii, 2020/04/26