https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114592

David C. Rankin <drankinatty at suddenlinkmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |drankinatty@suddenlinkmail.
                   |                            |com

--- Comment #7 from David C. Rankin <drankinatty at suddenlinkmail dot com> ---
I see this in C gcc (SUSE Linux) 16.2.1 20260929 with basic plane-old arrays
and -O3, but frustratingly random. There is no warning at -O2. The warning is
actually a bit ironic, because it does a great job showing the poa is
initialized while warning it may not be with:

$ gcc -Wall -Wextra -pedantic -Wshadow -march=native -std=c23 -O3 -o ptrarrneur
ptrarrneur.c layers.c -lm
In function ‘err_total’,
    inlined from ‘main’ at ptrarrneur.c:229:12:
ptrarrneur.c:130:19: warning: ‘target’ may be used uninitialized
[-Wmaybe-uninitialized]
  130 |     l->error[i] = erf (target[i], l->output[i], l->nneur);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ptrarrneur.c: In function ‘main’:
ptrarrneur.c:199:9: note: ‘target’ declared here
  199 |   float target[] = { .05, .95 },
      |         ^~~~~~

The function and initialization involved:

float err_total (layer_t *l, float *target, float (*erf)(float, float,
unsigned))
{
  float etotal = 0.;

  for (unsigned i = 0; i < l->nneur; i++) {
    l->error[i] = erf (target[i], l->output[i], l->nneur);
    etotal += l->error[i];
  }

  return etotal;
}


int main (void) {

  float target[] = { .05, .95 },
        etotal = 0.;

  /* compute total error */
  etotal = err_total (&l[NLAYERS - 1], target, err_mse);

}

I know this is C instead of C++, but the regression likely stems from the same
area in the compiler.

Reply via email to