Index: gcc/fortran/intrinsic.texi
===================================================================
--- gcc/fortran/intrinsic.texi	(revision 201904)
+++ gcc/fortran/intrinsic.texi	(working copy)
@@ -11546,7 +11546,7 @@ number of bytes occupied by the argument.  If the
 to is returned.  If the argument is of a derived type with @code{POINTER}
 or @code{ALLOCATABLE} components, the return value does not account for
 the sizes of the data pointed to by these components. If the argument is
-polymorphic, the size according to the declared type is returned. The argument
+polymorphic, the size according to the dynamic type is returned. The argument
 may not be a procedure or procedure pointer.
 
 @item @emph{Example}:
Index: gcc/fortran/trans-intrinsic.c
===================================================================
--- gcc/fortran/trans-intrinsic.c	(revision 201904)
+++ gcc/fortran/trans-intrinsic.c	(working copy)
@@ -5194,19 +5194,27 @@ gfc_conv_intrinsic_sizeof (gfc_se *se, gfc_expr *e
   if (arg->rank == 0)
     {
       if (arg->ts.type == BT_CLASS)
-	gfc_add_data_component (arg);
+	{
+	  gfc_add_vptr_component (arg);
+	  gfc_add_size_component (arg);
+	  gfc_conv_expr (&argse, arg);
+	  se->expr = fold_convert (gfc_array_index_type, argse.expr);
+	}
+      else
+	{
+	  gfc_conv_expr_reference (&argse, arg);
 
-      gfc_conv_expr_reference (&argse, arg);
+	  type = TREE_TYPE (build_fold_indirect_ref_loc (input_location,
+							 argse.expr));
 
-      type = TREE_TYPE (build_fold_indirect_ref_loc (input_location,
-						 argse.expr));
-
-      /* Obtain the source word length.  */
-      if (arg->ts.type == BT_CHARACTER)
-	se->expr = size_of_string_in_bytes (arg->ts.kind,
-					    argse.string_length);
-      else
-	se->expr = fold_convert (gfc_array_index_type, size_in_bytes (type)); 
+	  /* Obtain the source word length.  */
+	  if (arg->ts.type == BT_CHARACTER)
+	    se->expr = size_of_string_in_bytes (arg->ts.kind,
+						argse.string_length);
+	  else
+	    se->expr = fold_convert (gfc_array_index_type,
+				     size_in_bytes (type));
+	}
     }
   else
     {
Index: gcc/testsuite/gfortran.dg/storage_size_1.f08
===================================================================
--- gcc/testsuite/gfortran.dg/storage_size_1.f08	(revision 201904)
+++ gcc/testsuite/gfortran.dg/storage_size_1.f08	(working copy)
@@ -25,7 +25,7 @@ if (storage_size(a)  /= 64) call abort()
 if (sizeof(b)        /= 24) call abort()
 if (storage_size(b)  /= 64) call abort()
 
-if (sizeof(cp)       /=  8) call abort()
+if (sizeof(cp)       /= 12) call abort()
 if (storage_size(cp) /= 96) call abort()
 
 end
