https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112364

            Bug ID: 112364
           Summary: calloc used incorrectly
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: muecker at gwdg dot de
  Target Milestone: ---

As detected by -Walloc-size, there are some calls to calloc in libgfortran with
incorrectly ordered arguments.

See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112347#c10


../../../trunk.year/libgfortran/io/async.c:265:24: warning: allocation of
insufficient size ‘1’ for type ‘transfer_queue’ with size ‘80’ [-Walloc-size]
../../../trunk.year/libgfortran/io/async.c:287:24: warning: allocation of
insufficient size ‘1’ for type ‘transfer_queue’ with size ‘80’ [-Walloc-size]
../../../trunk.year/libgfortran/io/async.c:311:24: warning: allocation of
insufficient size ‘1’ for type ‘transfer_queue’ with size ‘80’ [-Walloc-size]
../../../trunk.year/libgfortran/io/async.c:331:24: warning: allocation of
insufficient size ‘1’ for type ‘transfer_queue’ with size ‘80’ [-Walloc-size]

  transfer_queue *tq = calloc (sizeof (transfer_queue), 1);


Note that for the allocated size the order of arguments does not matter, but -
at least according to my understanding - the alignment requirements for the
returned memory may depend on the object size being the second argument.

Reply via email to