Debian 12 gcc warning

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Debian 12 gcc warning
Дата
Msg-id ZOz3cBySkbEA5RN+@momjian.us
обсуждение исходный текст
Ответы Re: Debian 12 gcc warning  (Michael Paquier <michael@paquier.xyz>)
Re: Debian 12 gcc warning  (David Rowley <dgrowleyml@gmail.com>)
Re: Debian 12 gcc warning  ("Tristan Partin" <tristan@neon.tech>)
Список pgsql-hackers
On Debian 12, gcc version 12.2.0 (Debian 12.2.0-14) generates a warning
on PG 13 to current, but only with -O1 optimization level, and not at
-O0/-O2/-O3:

    clauses.c: In function ‘recheck_cast_function_args’:
    clauses.c:4293:19: warning: ‘actual_arg_types’ may be used uninitialized [-Wmaybe-uninitialized]
     4293 |         rettype = enforce_generic_type_consistency(actual_arg_types,
          |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     4294 |
declared_arg_types,
          |
~~~~~~~~~~~~~~~~~~~
     4295 |                                                                                            nargs,
          |                                                                                            ~~~~~~
     4296 |
funcform->prorettype,
          |
~~~~~~~~~~~~~~~~~~~~~
     4297 |                                                                                            false);
          |                                                                                            ~~~~~~
    In file included from clauses.c:45:
    ../../../../src/include/parser/parse_coerce.h:82:17: note: by argument 1 of type ‘const Oid *’ {aka ‘const unsigned
int*’} to ‘enforce_generic_type_consistency’ declared here
 
       82 | extern Oid      enforce_generic_type_consistency(const Oid *actual_arg_types,
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    clauses.c:4279:33: note: ‘actual_arg_types’ declared here
     4279 |         Oid                     actual_arg_types[FUNC_MAX_ARGS];
          |                                 ^~~~~~~~~~~~~~~~

The code is:

    static void
    recheck_cast_function_args(List *args, Oid result_type,
                               Oid *proargtypes, int pronargs,
                               HeapTuple func_tuple)
    {
        Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
        int         nargs;
        Oid         actual_arg_types[FUNC_MAX_ARGS];
        Oid         declared_arg_types[FUNC_MAX_ARGS];
        Oid         rettype;
        ListCell   *lc;
    
        if (list_length(args) > FUNC_MAX_ARGS)
            elog(ERROR, "too many function arguments");
        nargs = 0;
        foreach(lc, args)
        {
            actual_arg_types[nargs++] = exprType((Node *) lfirst(lc));
        }
        Assert(nargs == pronargs);
        memcpy(declared_arg_types, proargtypes, pronargs * sizeof(Oid));
-->        rettype = enforce_generic_type_consistency(actual_arg_types,
                                                   declared_arg_types,
                                                   nargs,
                                                   funcform->prorettype,
                                                   false);
        /* let's just check we got the same answer as the parser did ... */

I don't see a clean way of avoiding the warning except by initializing
the array, which seems wasteful.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  Only you can decide what is important to you.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: Eager page freeze criteria clarification
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Eager page freeze criteria clarification