Silence -Wmaybe-uninitialized warnings - Mailing list pgsql-hackers

From Imran Zaheer
Subject Silence -Wmaybe-uninitialized warnings
Date
Msg-id CA+UBfa=H9RQdZ8Tof+SF7gMC-FTrsJ_w=Vnxs4OiBAaB_go+tQ@mail.gmail.com
Whole thread
Responses Re: Silence -Wmaybe-uninitialized warnings
List pgsql-hackers
Hi

When building postgresql with CFLAGS="-Og" gcc emits
'-Wmaybe-uninitialized' warnings at few places. The variables are
initialized on all execution paths but the compiler was not able to
prove it with the additional optimization flag enabled. The patch
initializes the variables with NULL to silence the warnings. No
functional change intended.

```
[646/2085] Compiling C object
src/backend/postgres_lib.a.p/commands_copyfromparse.c.o
../src/backend/commands/copyfromparse.c: In function ‘CopyFromTextOneRow’:
../src/backend/commands/copyfromparse.c:995:39: warning:
‘field_strings’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
  995 |                 string = field_strings[fieldno++];
      |                                       ^
../src/backend/commands/copyfromparse.c:961:21: note: ‘field_strings’
was declared here
  961 |         char      **field_strings;
      |                     ^~~~~~~~~~~~~
../src/backend/commands/copyfromparse.c: In function ‘CopyFromCSVOneRow’:
../src/backend/commands/copyfromparse.c:995:39: warning:
‘field_strings’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
  995 |                 string = field_strings[fieldno++];
      |                                       ^
../src/backend/commands/copyfromparse.c:961:21: note: ‘field_strings’
was declared here
  961 |         char      **field_strings;
      |                     ^~~~~~~~~~~~~
[889/2085] Compiling C object
src/backend/postgres_lib.a.p/partitioning_partbounds.c.o
../src/backend/partitioning/partbounds.c: In function
‘check_partition_bounds_for_split_range’:
../src/backend/partitioning/partbounds.c:5452:57: warning: ‘datum’ may
be used uninitialized in this function [-Wmaybe-uninitialized]
 5452 |
parser_errposition(pstate, exprLocation((Node *) datum)));
      |
```
gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0


Regards
Imran Zaheer

Attachment

pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Changing the state of data checksums in a running cluster
Next
From: Richard Guo
Date:
Subject: Re: Fix HAVING-to-WHERE pushdown with nondeterministic collations