Change strict-aliasing warning level?

Morten Brørup mb at smartsharesystems.com
Sun Aug 30 13:41:44 CEST 2026


Grout is built with -Wstrict-aliasing=2 [BUILD].

This requires type casting to the generic "void *", as done in the patch introducing strict-aliasing [STRICT-ALIAS-PATCH], like this:

	struct conn *conn;
	// create a new connection object
	if (rte_mempool_get(conn_pool, (void *)&conn) < 0)
		return NULL;

Or extra "void *" variables for type conversion only, like this [CONNTRACK]:

	struct conn *conn;
	void *data;
	// create a new connection object
	if (rte_mempool_get(conn_pool, &data) < 0)
		return NULL;
	conn = data;

With -Wstrict-aliasing=3, we could use more accurate type casting, like this:

	struct conn *conn;
	// create a new connection object
	if (rte_mempool_get(conn_pool, (void **)&conn) < 0)
		return NULL;


For reference, rte_mempool_get is declared as:

static __rte_always_inline int
rte_mempool_get(struct rte_mempool *mp, void **obj_p);


WDYT about changing -Wstrict-aliasing=2 to -Wstrict-aliasing=3, the default strict-aliasing warning level [WARNING-OPTIONS]?

Grout currently compiles just fine with -Wstrict-aliasing=3.


[BUILD]: https://github.com/DPDK/grout/blob/819435ff2e048fa696c6e57bcef43626ce398021/meson.build#L36
[CONNTRACK]: https://github.com/DPDK/grout/blob/819435ff2e048fa696c6e57bcef43626ce398021/modules/policy/control/conntrack.c#L360
[STRICT-ALIAS-PATCH]: https://github.com/DPDK/grout/commit/289dac98d9f43bec2aedfadc4e02ba84718ac761
[WARNING-OPTIONS]: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstrict-aliasing



More information about the grout mailing list