Does typedef VLA require evaluation of the size expression?
int f(void);
int main(void)
{
typedef int (T) [ f() ]; // is f required to be evaluated ?
T x;
return sizeof x;
}
Does typedef pointer to VLA require evaluation of the size expression?
int f(void);
int main(void)
{
typedef int (*T) [ f() ]; // is f is required to be evaluated ?
T x;
return sizeof x;
}
UPD. In the definition of f is visible, then a call to it may be optimized out:
int f(void)
{
return 4;
}
int main(void)
{
typedef int (*T) [ f() ];
return sizeof(T);
}
Generated code (both GCC and LLVM):
main:
mov eax, 8
ret
It is expected, because there is no real need to call f to determine the size of a pointer.