Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Used-uninitalized error I hadn't seen before



On Fri, Sep 7, 2018 at 4:22 PM, Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:
>
> What compiler is this and what options? I don't get the warning with any
> compiler I've got. It'd be useful to track down which uses of the
> variable cause the warning.

This is on what I have to assume (I'm not the admin) is a stock CentOS 6.9 host:

gcc -c -I. -I../../Src -I../../Src -I../../Src/Zle -I.
-DHAVE_CONFIG_H -DMODULE -Wall -Wmissing-prototypes -O2 -fPIC -o
computil..o computil.c

gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)

> I'm fairly sure that it is wrong and grplen can't be used uninitialized.

So we have this:

   1847             if (sep > x) { /* exclusion included a set or group name */
   1848                 grp = x;
   1849                 grplen = sep - grp;
   1850                 x = sep;
   1851             }

and then later uses of grplen are protected by expressions like

   1853             if (excludeall || (x[0] == ':' && !x[1])) {
   1854                 if (grp) {

e.g., at line 1858 grplen is passed to strncmp() and at line 1859 is
used in a subscript.  It's not obvious to me why the conditions on
1853-1854 are a superset of 1847.



Messages sorted by: Reverse Date, Date, Thread, Author