Issue 1045: Are VLAs adjusted to pointers variably modified?

Authors: Michael Forney
Date: 2026-04-22
Submitted against: C23
Status: Open
Cross-references: 0311

Example 1 in C23 6.5.3.6 uses a function definition with a VLA parameter that gets adjusted to a pointer, and it claimed that the length expression should be evaluated on function entry.

This isn't clear to me from the standard text, and it seems different implementations seem to interpret it in different ways.

Consider a similar example here:

#include <stdio.h>
int x;
int f(int a[x += 1]) {
        typeof(x += 2, a) b;
        printf("x=%d\n", x);
        return x;
}
int main(void) {
        f(0);
}

C23 6.7.7.4p6 says

A declaration of a parameter as "array of type" shall be adjusted to "qualified pointer to type", where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation.

From this, it's clear that a's type is adjusted to int *.

C23 defines a variably modified type in 6.7.7.1p3:

If, in the nested sequence of declarators in a full declarator, there is a declarator specifying a variable length array type, the type specified by the full declarator is said to be variably modified. Furthermore, any type derived by declarator type derivation from a variably modified type is itself variably modified.

This establishes the term "variably modified" as a property of the type.

C23 6.9.2p11 describes when variably modified types used in the prototype are evaluated:

On entry to the function, the size expressions of each variably modified parameter and typeof operators used in declarations of parameters are evaluated and the value of each argument expression is converted to the type of the corresponding parameter as if by assignment.

Here, it refers to a "variably modified parameter". Since this is a property of a type, I assume this means a parameter with a variably modified type. The expression x += 1 should be evaluated iff a is a "variably modified parameter".

In the function body, there is a typeof specifier containing a comma expression which has the same type as a. According to C23 6.7.3.6:

If the type of the operand is a variably modified type, the operand is evaluated; otherwise, the operand is not evaluated.

So the expression x += 2 should be evaluated iff a has a variably modified type.

It seems to me that either both of these expressions should be evaluated, or neither should be evaluated. Existing implementations seem to disagree. gcc prints 1, clang prints 3, icc prints 1, tcc prints 0, and cproc (my compiler) prints 0.

I think the standard should clarify whether parameter types that get adjusted from VLAs to pointers retain their "variably modified"-ness even if there is no VLA in the resulting derivation.