diff --git a/src/include/access/heapam_xlog.h b/src/include/access/heapam_xlog.h
index 3f79c389a90..33805f13afe 100644
--- a/src/include/access/heapam_xlog.h
+++ b/src/include/access/heapam_xlog.h
@@ -141,7 +141,7 @@ typedef struct xl_heap_truncate
 	Oid			dbId;
 	uint32		nrelids;
 	uint8		flags;
-	Oid			relids[FLEXIBLE_ARRAY_MEMBER];
+	pg_attribute_counted_by(nrelids) Oid			relids[FLEXIBLE_ARRAY_MEMBER];
 } xl_heap_truncate;
 
 #define SizeOfHeapTruncate	(offsetof(xl_heap_truncate, relids))
@@ -194,7 +194,7 @@ typedef struct xl_heap_multi_insert
 {
 	uint8		flags;
 	uint16		ntuples;
-	OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
+	pg_attribute_counted_by(ntuples) OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
 } xl_heap_multi_insert;
 
 #define SizeOfHeapMultiInsert	offsetof(xl_heap_multi_insert, offsets)
@@ -402,7 +402,7 @@ typedef struct xlhp_freeze_plan
 typedef struct xlhp_freeze_plans
 {
 	uint16		nplans;
-	xlhp_freeze_plan plans[FLEXIBLE_ARRAY_MEMBER];
+	pg_attribute_counted_by(nplans) xlhp_freeze_plan plans[FLEXIBLE_ARRAY_MEMBER];
 } xlhp_freeze_plans;
 
 /*
@@ -415,7 +415,7 @@ typedef struct xlhp_freeze_plans
 typedef struct xlhp_prune_items
 {
 	uint16		ntargets;
-	OffsetNumber data[FLEXIBLE_ARRAY_MEMBER];
+	pg_attribute_counted_by(ntargets) OffsetNumber data[FLEXIBLE_ARRAY_MEMBER];
 } xlhp_prune_items;
 
 
@@ -470,7 +470,7 @@ typedef struct xl_heap_inplace
 	Oid			tsId;			/* MyDatabaseTableSpace */
 	bool		relcacheInitFileInval;	/* invalidate relcache init files */
 	int			nmsgs;			/* number of shared inval msgs */
-	SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER];
+	pg_attribute_counted_by(nmsgs) SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER];
 } xl_heap_inplace;
 
 #define MinSizeOfHeapInplace	(offsetof(xl_heap_inplace, nmsgs) + sizeof(int))
diff --git a/src/include/access/xact.h b/src/include/access/xact.h
index a8cbdf247c8..1d94e38b7c3 100644
--- a/src/include/access/xact.h
+++ b/src/include/access/xact.h
@@ -220,7 +220,7 @@ typedef struct xl_xact_assignment
 {
 	TransactionId xtop;			/* assigned XID's top-level XID */
 	int			nsubxacts;		/* number of subtransaction XIDs */
-	TransactionId xsub[FLEXIBLE_ARRAY_MEMBER];	/* assigned subxids */
+	pg_attribute_counted_by(nsubxacts) TransactionId xsub[FLEXIBLE_ARRAY_MEMBER];	/* assigned subxids */
 } xl_xact_assignment;
 
 #define MinSizeOfXactAssignment offsetof(xl_xact_assignment, xsub)
@@ -262,14 +262,14 @@ typedef struct xl_xact_dbinfo
 typedef struct xl_xact_subxacts
 {
 	int			nsubxacts;		/* number of subtransaction XIDs */
-	TransactionId subxacts[FLEXIBLE_ARRAY_MEMBER];
+	pg_attribute_counted_by(nsubxacts) TransactionId subxacts[FLEXIBLE_ARRAY_MEMBER];
 } xl_xact_subxacts;
 #define MinSizeOfXactSubxacts offsetof(xl_xact_subxacts, subxacts)
 
 typedef struct xl_xact_relfilelocators
 {
 	int			nrels;			/* number of relations */
-	RelFileLocator xlocators[FLEXIBLE_ARRAY_MEMBER];
+	pg_attribute_counted_by(nrels) RelFileLocator xlocators[FLEXIBLE_ARRAY_MEMBER];
 } xl_xact_relfilelocators;
 #define MinSizeOfXactRelfileLocators offsetof(xl_xact_relfilelocators, xlocators)
 
@@ -296,14 +296,14 @@ typedef struct xl_xact_stats_item
 typedef struct xl_xact_stats_items
 {
 	int			nitems;
-	xl_xact_stats_item items[FLEXIBLE_ARRAY_MEMBER];
+	pg_attribute_counted_by(nitems) xl_xact_stats_item items[FLEXIBLE_ARRAY_MEMBER];
 } xl_xact_stats_items;
 #define MinSizeOfXactStatsItems offsetof(xl_xact_stats_items, items)
 
 typedef struct xl_xact_invals
 {
 	int			nmsgs;			/* number of shared inval msgs */
-	SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER];
+	pg_attribute_counted_by(nmsgs) SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER];
 } xl_xact_invals;
 #define MinSizeOfXactInvals offsetof(xl_xact_invals, msgs)
 
