Harmless warnings during compilation

Hi, i’ve just updated swi by pulling from github. During the compilation i get the following warnings, i don’t know if it is worth fixing them.

In file included from swipl-devel/src/pl-wam.c:2965:0:
swipl-devel/src/pl-wam.c: In function ‘PL_next_solution’:
swipl-devel/src/pl-vmi.c:4964:8: warning: ‘args’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   Word args;
    ^
swipl-devel/src/pl-vmi.c:5296:8: warning: ‘arity’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   { if ( arity > MAXARITY )
    ^
swipl-devel/src/pl-vmi.c:4963:7: note: ‘arity’ was declared here
   int arity;
   ^
In file included from swipl-devel/src/pl-incl.h:2498:0,
             from swipl-devel/src/pl-wam.c:38:
  swipl-devel/src/pl-ldpass.h:76:51: warning: ‘functor’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 #define resolveProcedure(f,m) resolveProcedure__LD(f, m PASS_LD)
                                               ^
In file included from swipl-devel/src/pl-wam.c:2965:0:
swipl-devel/src/pl-vmi.c:4962:13: note: ‘functor’ was declared here
   functor_t functor;

swipl-devel/src/pl-gmp.c: In function ‘mpz_fdiv.isra.9’:
swipl-devel/src/pl-gmp.c:1543:17: warning: ‘r_mode’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   fesetround(r_mode);

In file included from swipl-devel/src/pl-thread.h:39:0,
             from swipl-devel/src/pl-incl.h:2490,
             from swipl-devel/src/pl-tabling.c:36:
swipl-devel/src/pl-tabling.c: In function ‘simplify_delay_set’:
swipl-devel/src/os/pl-buffer.h:142:39: warning: value computed is not used [-Wunused-value]
  ((b)->top -= sizeof(type), (type*)(b)->top)
                                   ^
swipl-devel/src/pl-tabling.c:1012:7: note: in expansion of macro ‘popBufferP’
   popBufferP(&di->delay_sets, delay_set);
1 Like

Thanks for reporting. Which compiler is this? I’m using gcc-7, gcc-9 and gcc-10 and clang from Xcode 11 on Macos. All are silent (except for one class member variable in swipl-win that is claimed to be unused by Clang, but if you remove it it fails to compile because it is undefined :slight_smile: ).

Each compiler has its own false negatives and positives when it comes to such warnings. If these warnings are from an older compiler it is barely worth checking. If it comes from a newer compiler I typically check them. Sometimes there is something real and in any case I want to have silent compilation for modern compilers.

On the other hand, I try to minimize useless initialization. That suppresses such warnings, but if you expect each branch to initialize some variable such messages nicely indicate you forgot to deal with some condition.

1 Like

Actually, the compiler version is pretty old. I’m on CentOS 7 and the version of gcc is 4.8.5 (i’m on a cluster and i’m not the maintainer).

$> gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)

Thanks. I guess we better ignore these warnings in this case :slight_smile: I think this is one of the oldest GCC versions that works for recent SWI-Prolog versions after we switched to GCC’s new atomic instruction support …

1 Like