On Thu, Jan 30, 2025 at 10:01 AM Dmitry Antipov <dmanti...@yandex.ru> wrote:
>
> With (probably) -Wmaybe-uninitialized and/or -Wextra, shouldn't the compiler 
> emit
> warning about possibly uninitialized 'y' passed to 'ddd()' in the example 
> below?
>
> struct T {
>    int a;
>    int b;
> };
>
> extern int bbb (struct T *, int *);
> extern int ccc (struct T *, int *);
> extern int ddd (struct T *, int);
>
> int
> aaa (struct T *t)
> {
>    int x = 0, y;         /* 'y' is uninitialized */
>
>    if (t->a)             /* if this condition is true */
>      goto l;
>
>    x += bbb (t, &y);

We consider bbb to likely initialize 'y', so do not diagnose the use
on the ddd call
below.

>
>   l:
>    if (t->b)             /* and this condition is false */
>        x += ccc (t, &y);
>
>    x += ddd (t, y);      /* then 'y' is passed to ddd() uninitialized */
>
>    return x;
> }
>
> Dmitry
>

Reply via email to