Closed ranaanoop closed 4 months ago
Basically, apart from making the note[expr.const.cast#6] normative, we may need to clarify if
modify == write OR
modify == change
[expr.ass] p2 clearly says that assignment "modifies", independent of the values involved.
@jensmaurer I see, so there doesn't seem to be an immediate need to define "modify".
Full name of submitter: Anoop Rana
Reference (section label): [dcl.type.cv], [intro.abstract]
Issue description:
Consider the code:
Currently it is not clear normatively(since there is a note available but a note is non-normative) if
const int i = 1;*const_cast<int*>(&i) = 1;
in the above program is UB. In particular, dcl.type.cv says:Note the emphasis on the word "modify". But in the example above, we aren't actually "modifying" the old value. Instead we're assigning a value which is the same a the old one. So it is not clear if [dcl.type.cv#4] quoted above is applicable here. The problem mainly is due to the lack of formal definition for the term "modify"
Similarly, there is [intro.abstract#4] that says:
Here again the word modify is used.
There is however a note available in expr.const.cast#6 that makes the program UB.
So the above note is applicable for the program but the problem is that it is not normative. I suggest to make it normative by removing the Note from [expr.const.cast#6].