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

            Bug ID: 121197
           Summary: -Wcalloc-transposed-args warning is 100% useless
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nfxjfg at googlemail dot com
  Target Milestone: ---

Relatively recently, this warning got added to one of the default warnings.

I claim that it is 100% useless, doesn't fix a single bug, only causes a lot of
confusion, and should be disabled.

While on a formal level, the warning is correct, there is no difference in
semantics between calloc(a,b) and calloc(b,a). calloc(a,b) is 100% semantically
equivalent to calloc(a*b,1) or malloc(a*b)+memset() (minus the overflow check).
There is no magic that requires the first argument of calloc() to be actually
the number of array items if an array is allocated. (Probably) no analyzer
assigns special meaning to the order of the arguments.

Reply via email to