This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] assert: Suppress pedantic warning caused by statement expression [BZ# 21242]


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]