Changeset View
Standalone View
contrib/mandoc/out.c
| Show First 20 Lines • Show All 451 Lines • ▼ Show 20 Lines | default: | ||||
| abort(); | abort(); | ||||
| } | } | ||||
| } | } | ||||
| static size_t | static size_t | ||||
| tblcalc_literal(struct rofftbl *tbl, struct roffcol *col, | tblcalc_literal(struct rofftbl *tbl, struct roffcol *col, | ||||
| const struct tbl_dat *dp, size_t mw) | const struct tbl_dat *dp, size_t mw) | ||||
| { | { | ||||
| const char *str; /* Beginning of the first line. */ | char *str; /* Beginning of the first line. */ | ||||
| const char *beg; /* Beginning of the current line. */ | char *beg; /* Beginning of the current line. */ | ||||
markmi_dsl-only.net: Previously the declaration of the above 2 pointers indicated explicitly that they were not… | |||||
ivyAuthorUnsubmitted Done Inline Actions
they were being used to mutate the state and the compiler was unable to validate this because the pre-C23 strchr() silently deconstifies its input. by removing const, it is now clear that they are being used to mutate state. if you think this change is wrong, please explain why. ivy: > Previously the declaration of the above 2 pointers indicated explicitly that they were not… | |||||
markmi_dsl-only.netUnsubmitted Not Done Inline ActionsIf they were being used to mutate the state, does the compiler reject the source code in the C23 context when the 2 const are present? If not, the compiler disagrees with the classification of the pointers being dereferenced to do mutation (no *str= EXPRESSION; or *beg= EXPRESSION; or end=beg; [dropping const] the like for it to reject). As error messages were not presented, I had to infer the details. If the C23 compiler context rejects declaring the 2 with const put back in, then my apologies for the noise. markmi_dsl-only.net: If they were being used to mutate the state, does the compiler reject the source code in the… | |||||
markmi_dsl-only.netUnsubmitted Not Done Inline ActionsI just got this wrong, as there is dropping const activity otherwise. Sorry for the noise. (I do now have an environment for doing compiler cross checks of such modern things before I consider commenting.) markmi_dsl-only.net: I just got this wrong, as there is dropping const activity otherwise. Sorry for the noise. (I… | |||||
| char *end; /* End of the current line. */ | char *end; /* End of the current line. */ | ||||
| /* Widths in basic units. */ | /* Widths in basic units. */ | ||||
| size_t lsz; /* Of the current line. */ | size_t lsz; /* Of the current line. */ | ||||
| size_t wsz; /* Of the current word. */ | size_t wsz; /* Of the current word. */ | ||||
| size_t msz; /* Of the longest line. */ | size_t msz; /* Of the longest line. */ | ||||
| size_t enw; /* Of one EN unit. */ | size_t enw; /* Of one EN unit. */ | ||||
| ▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines | |||||
Previously the declaration of the above 2 pointers indicated explicitly that they were not being used directly to mutate the state and the compiler validated such. Also, given that, the below declaration indicated it was the actual pointer of the 3 that is directly used to mutate the state.
Now, which of the 3 pointers are used to mutate the state is not explicitly declared and the code must be manually analyzed to figure that out and the compiler cannot check on the status that it previously could.
For C and C++, a specific pointer that is declared as not being used to mutate state does not mean that the referenced state needs to be invariant relative to other means of doing mutation of the same state over any scope or time frame.
So I could imagine some feedback from sending this upstream, given how it was originally written.