https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122677
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -4939,8 +4939,13 @@ maybe_add_cmi_prefix (const char *to, size_t *len_p =
NULL)
static void
create_dirs (char *path)
{
+ char *base = path;
+ /* Skip past initial slashes of absolute path. */
+ while (IS_DIR_SEPARATOR (*base))
+ base++;
+
/* Try and create the missing directories. */
- for (char *base = path; *base; base++)
+ for (; *base; base++)
if (IS_DIR_SEPARATOR (*base))
{
char sep = *base;