diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 1e6b593163d521ad35761917a753f36d93352c29..f245cb4d7c05c9576b957809aa538626080015b2 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2020-04-29  Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>
+
+	PR fortran/94769
+	* io.c (check_io_constraints): Initialize local variable num to
+	-1 and assert that it receives a meaningful value by function
+	compare_to_allowed_values.
+
 2020-04-27  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
 	PR fortran/93956
diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c
index e066666e01d14d2c4ad4a6f5afed1ee10b9172f8..981cf9e88ddeb7433436f25b47e47bdbef6261d3 100644
--- a/gcc/fortran/io.c
+++ b/gcc/fortran/io.c
@@ -3840,7 +3840,7 @@ if (condition) \
 
   if (dt->asynchronous)
     {
-      int num;
+      int num = -1;
       static const char * asynchronous[] = { "YES", "NO", NULL };
 
       /* Note: gfc_reduce_init_expr reports an error if not init-expr.  */
@@ -3853,6 +3853,8 @@ if (condition) \
 		 io_kind_name (k), warn, &dt->asynchronous->where, &num))
 	return false;
 
+      gcc_checking_assert (num != -1);
+
       /* For "YES", mark related symbols as asynchronous.  */
       if (num == 0)
 	{