Skip to content

fix: correct int/int32_t pointer mismatches for -Wincompatible-pointer-types - #1657

Merged
bnoordhuis merged 1 commit into
quickjs-ng:masterfrom
SomSamantray:fix/int32-pointer-mismatch
Sep 3, 2026
Merged

bnoordhuis merged 1 commit into
quickjs-ng:masterfrom
SomSamantray:fix/int32-pointer-mismatch

Conversation

@SomSamantray

@SomSamantray SomSamantray commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

On any target whose stdint.h defines int32_t as long int rather than int — every ESP-IDF/ESP32 chip since v5.0 — quickjs.c fails to compile under GCC 14+, because -Wincompatible-pointer-types is now an error by default there. Six call sites across five local variables pass an int * where an int32_t * is expected, or the reverse.

Both types are 32-bit signed on every platform this project targets, so there's no behavioral difference — this retypes the five local variables (find_line_num's v, js_parseInt's radix, remainingElementsCount_add's remainingElementsCount, js_promise_all_resolve_element's index, and js_atomics_notify's count) to match the callee signature each is already used against everywhere else in the file. No callee signatures changed.

Verified locally without ESP32 hardware or a GCC 14 install: shimming int32_t to a distinct-but-same-width type and compiling with clang -std=gnu11 -Werror=incompatible-pointer-types reproduces the exact 6 errors at the exact reported lines before the fix, and compiles clean after. Also confirmed the normal (unshimmed) build still succeeds, api-test passes, and manually exercised parseInt('ff', 16) and Atomics.notify to confirm unchanged behavior.

Fixes #1624

…r-types

Six call sites pass an int* where int32_t* is expected (or the
reverse) in find_line_num, js_parseInt, remainingElementsCount_add,
js_promise_all_resolve_element, and js_atomics_notify. Both types are
32-bit signed everywhere this project targets, so there is no
behavioral change, but on any target where stdint.h defines int32_t
as long int (ESP-IDF/ESP32 since v5.0), GCC 14+ treats the mismatch
as a hard -Wincompatible-pointer-types error and the file fails to
build. Retype the five local variables to match the callee signature
already used at every other call site.
@saghul

saghul commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Drop the plan

@bnoordhuis

Copy link
Copy Markdown
Contributor

ping @SomSamantray

@SomSamantray
SomSamantray force-pushed the fix/int32-pointer-mismatch branch from 316e14e to 335ffae Compare September 3, 2026 02:21
@SomSamantray

Copy link
Copy Markdown
Contributor Author

Dropped the plan doc from the branch (rebased it out) and pushed — the PR is now scoped to the single quickjs.c type fix. Also re-verified: normal build + api-test pass, and re-ran the int32_t-shim repro from the description to confirm all 6 originally-reported sites now compile clean under -Werror=incompatible-pointer-types.

@SomSamantray

Copy link
Copy Markdown
Contributor Author

Drop the plan

Done — rebased the branch to drop that commit entirely. The PR is now scoped to the single quickjs.c type fix (commit 335ffae), no other files.

@SomSamantray

Copy link
Copy Markdown
Contributor Author

ping @SomSamantray

Responded — see the comment above. Plan doc dropped, fix re-verified (clean build, api-test passes, int32_t-shim repro confirms all 6 reported call sites now compile clean under -Werror=incompatible-pointer-types), and the PR body no longer has the tooling badge. Ready for another look whenever convenient.

@bnoordhuis
bnoordhuis merged commit d8e1cc6 into quickjs-ng:master Sep 3, 2026
128 checks passed
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.

quickjs.c fails to compile on targets where int32_t is long int (ESP-IDF / bare-metal newlib): -Wincompatible-pointer-types

3 participants