diff --git a/src/win32/win_cd.c b/src/win32/win_cd.c
index ac1cda8ae96632a63e657b44511b31b04531e54b..813e0625917ab07b5d6bbb29a3caa48ee8f66577 100644
--- a/src/win32/win_cd.c
+++ b/src/win32/win_cd.c
@@ -169,6 +169,10 @@ consvar_t cd_volume = {"cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL, 0, NUL
 // (on those Update can be disabled)
 consvar_t cdUpdate  = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
 
+#if (__GNUC__ > 6)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Werror=format-overflow"
+#endif
 // hour,minutes,seconds
 static LPSTR hms(UINT seconds)
 {
@@ -180,11 +184,14 @@ static LPSTR hms(UINT seconds)
 	hours = minutes / 60;
 	minutes %= 60;
 	if (hours > 0)
-		sprintf (s, "%lu:%02u:%02u", (long unsigned int)hours, (unsigned char)(minutes%99), (unsigned char)(seconds%99));
+		sprintf (s, "%lu:%02lu:%02lu", (long unsigned int)hours, (long unsigned int)minutes, (long unsigned int)seconds);
 	else
-		sprintf (s, "%2u:%02u", (unsigned char)(minutes%99), (unsigned char)(seconds%99));
+		sprintf (s, "%2lu:%02lu", (long unsigned int)minutes, (long unsigned int)seconds);
 	return s;
 }
+#if (__GNUC__ > 6)
+#pragma GCC diagnostic pop
+#endif
 
 static void Command_Cd_f(void)
 {