LWG 2475 made this valid by editing the specification of operator[](size()) (inserted text in bold):
Otherwise, returns a reference to an object of type charT with value
charT(), where modifying the object to any value other than charT()
leads to undefined behavior.