At least gcc-13 triggers -Wanalyzer-use-of-uninitialized-value for
code like (compile with -D_TIME_BITS=64 if using glibc; requires glibc
>= 2.34) :

  struct timespec f(void)
  {
    struct timespec t;
    t.tv_sec = 0;
    t.tv_nsec = 0;
    return t;
  }

Which seems to be common, and that could be silenced by initializing
the variable first (ex: t = {0}).

The 4 byte padding will be added either before or after tv_nsec,
depending on endianness, and is IMHO harmless even if uninitialized,
but it is not a false positive, so not sure if suppressing it might be
worth considering.

Either way, worth addressing, and if so, which way?

Carlo

Reply via email to