https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93955
Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid --- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> --- The problem is that /* Technically we should check this for all subexpressions, but that runs into problems with our internal representation of pointer subtraction and the 5.19 rules are still in flux. */ if (CONVERT_EXPR_CODE_P (TREE_CODE (r)) && ARITHMETIC_TYPE_P (TREE_TYPE (r)) && TREE_CODE (TREE_OPERAND (r, 0)) == ADDR_EXPR) { if (!allow_non_constant) error ("conversion from pointer type %qT " "to arithmetic type %qT in a constant expression", TREE_TYPE (TREE_OPERAND (r, 0)), TREE_TYPE (r)); non_constant_p = true; } only works on the outermost expression, as the comment says. Looks like a GCC 11 project.