2 ms·
Oh, wow thanks. I made sure to check the strings are modifiable, but that *argv may not be modifiable never occurred to me, I suppose this is an easy enough fix
by camel-cdr 4y ago
Oh, wow thanks. I made sure to check the strings are modifiable, but that *argv may not be modifiable never occurred to me, I suppose this is an easy enough fix, I'll look into it later.
Edit: I just saw this SO comment [0]:
> The standard calls argv consistently an array. Modifying an array refers to modifying its members. Thus, it seems obvious that the wording in the standard refers to modifying the members in the argv array, when it states that argv is modifiable.
It is still a mater of interpretation so you shouldn't depend on it.
[0] https://stackoverflow.com/questions/35105918/are-the-pointers-to-strings-in-argv-modifiable https://stackoverflow.com/questions/35105918/are-the-pointer...
- kazinator 4y agoI don't see the interpretation issue. The "parameters argc and argv" are the scalar, local variables. "argv array" is the object that "parameter argv" points to; it is not a parameter. The modifiability of argv was the subject of at three items in 1998 in meeting n849. https://www.open-std.org/jtc1/sc22/wg14/www/docs/n849.htm https://www.open-std.org/jtc1/sc22/wg14/www/docs/n849.htm Someone proposed that clarifying text be added saying "Whether or not the pointers of the argv array shall be modifiable by the program is implementation-defined. If they are modifiable, they shall retain their last-stored values between program startup and program termination." This was rejected due to insufficient interest. It was proposed that, since of course parameters are modifiable, the sentence in question be shortened to "The strings pointed to by the argv array shall be modifiable by the program, and retain their last-stored values between program startup and program termination", omitting the mention of "parameters argc and argv". This was discussed, but not accepted. The question was raised whether the pointers are modifiable. Response was: "This is currently implictly unspecified and the committee has chosen to leave it that way."