[PATCH] assert: Suppress pedantic warning caused by statement expression [BZ# 21242]
Florian Weimer
fweimer@redhat.com
Wed Jul 5 15:51:00 GMT 2017
On 07/05/2017 05:46 PM, Zack Weinberg wrote:
> A problem occurs to me: expressions involving VLAs _are_ evaluated
> inside sizeof. Consider
>
> extern int f(int);
> void g(void)
> {
> const int n = 4;
> int array[n] = { 0, 0, 0, 0 }; // in C99, array is a VLA
> assert(array[f(n)] == 0);
> }
>
> f() should be called only once, but I _think_ it will be called twice
> with this definition of assert.
The type of the sizeof argument would still be int (due to the
comparison against 0), so this doesn't actually occur.
Florian
More information about the Libc-alpha
mailing list