https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110791
--- Comment #2 from Alex Coplan <acoplan at gcc dot gnu.org> --- (In reply to Xi Ruoyao from comment #1) > Isn't this a UB? > > while (p >= path && *p != '/') > p--; > > This will cause p to become "&main::path[0] - 1". C23 6.5.6p9: In this case, with the input given in main, I think p should end up pointing to main::path + 1 (since we pass in main::path + 2, and foo can only ever decrement p at most one below its parameter path).