Skip to content

Fix (harmless) gcc warning calloc-transposed-args - #933

Merged
avsm merged 1 commit into
ocaml-multicore:mainfrom
talex5:fix-calloc-order
Sep 8, 2026
Merged

Fix (harmless) gcc warning calloc-transposed-args#933
avsm merged 1 commit into
ocaml-multicore:mainfrom
talex5:fix-calloc-order

Conversation

@talex5

@talex5 talex5 commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator
fork_action.c:101:28: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
  101 |   char **c = calloc(sizeof(char *), n + 1);
      |                            ^~~~
fork_action.c:101:28: note: earlier argument should specify number of elements, later size of each element

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

    fork_action.c:101:28: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
      101 |   char **c = calloc(sizeof(char *), n + 1);
          |                            ^~~~
    fork_action.c:101:28: note: earlier argument should specify number of elements, later size of each element

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

avsm commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Hah, I wrote something like this for OpenBSD back in 2003! Fix is obviously correct and we can't use caml_ functions in there.

@avsm
avsm merged commit accd8c0 into ocaml-multicore:main Sep 8, 2026
5 checks passed
@talex5
talex5 deleted the fix-calloc-order branch September 8, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants