Hacker News new | ask | show | jobs
by shultays 1463 days ago
Since new[] does not actually return an array (returns a pointer to 1-past-the last element in "" string/array) and later "this" pointer is calculated using an arithmetic operation that goes out of bounds (for elements that > 0), that would also be UB. ""+2 would be UB for example.

But maybe it is not UB because it is not calculated explicitly by the program, hard to tell