Skip to content

Commit

Permalink
Fix calloc-transposed-args with prism (#9810)
Browse files Browse the repository at this point in the history
GCC 14 was release on 7th May[^1]. It introduced a new warning `-Wno-calloc-transposed-args`[^2] designd to raise a warning when the arguments to `calloc` were given in the wrong order.

Unfortunately, `prism` version `0.24.0` made this mistake. Attempting to `bundle install` Dependabot gives the error:

<details>
<summary>Error details</summary>

```
src/diagnostic.c: In function ‘pm_diagnostic_list_append’:
src/diagnostic.c:328:69: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  328 |     pm_diagnostic_t *diagnostic = (pm_diagnostic_t *) calloc(sizeof(pm_diagnostic_t), 1);
      |                                                                     ^~~~~~~~~~~~~~~
src/diagnostic.c:328:69: note: earlier argument should specify number of elements, later size of each element
src/diagnostic.c: In function ‘pm_diagnostic_list_append_format’:
src/diagnostic.c:359:69: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  359 |     pm_diagnostic_t *diagnostic = (pm_diagnostic_t *) calloc(sizeof(pm_diagnostic_t), 1);
      |                                                                     ^~~~~~~~~~~~~~~
src/diagnostic.c:359:69: note: earlier argument should specify number of elements, later size of each element
cc1: all warnings being treated as errors
```

</details>

The issue was logged upstream in ruby/prism#2645, fixed in ruby/prism#2648, and released in https://github.com/ruby/prism/releases/tag/v0.25.0.

This change upgrades `prism`, by way of upgrading `rbi`, and resolves the compile error.

[^1]: https://gcc.gnu.org/gcc-14/
[^2]: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-calloc-transposed-args
  • Loading branch information
JamieMagee authored May 27, 2024
1 parent 1501dcc commit 7afe317
Show file tree
Hide file tree
Showing 3 changed files with 19,137 additions and 12,191 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,15 @@ GEM
parser (3.3.1.0)
ast (~> 2.4.1)
racc
prism (0.24.0)
prism (0.29.0)
psych (5.1.2)
stringio
public_suffix (5.0.4)
racc (1.7.3)
rainbow (3.1.1)
rake (13.1.0)
rbi (0.1.10)
prism (>= 0.18.0, < 0.25)
rbi (0.1.13)
prism (>= 0.18.0, < 1.0.0)
sorbet-runtime (>= 0.5.9204)
rdoc (6.6.3.1)
psych (>= 4.0.0)
Expand Down
Loading

0 comments on commit 7afe317

Please sign in to comment.