Skip to content

Fix GCC 16 incompatible-pointer return in IoFile_readUArrayOfLength_#499

Merged
stevedekorte merged 1 commit into
masterfrom
fix/gcc16-incompatible-pointer-readUArray
Jun 26, 2026
Merged

Fix GCC 16 incompatible-pointer return in IoFile_readUArrayOfLength_#499
stevedekorte merged 1 commit into
masterfrom
fix/gcc16-incompatible-pointer-readUArray

Conversation

@stevedekorte

Copy link
Copy Markdown
Member

Problem

Reported in #498: the native VM fails to build with GCC 16, which promotes -Wincompatible-pointer-types to a hard error by default. The reporter worked around it with CFLAGS=-Wno-error=incompatible-pointer-types, but there's a genuine bug underneath.

IoFile_readUArrayOfLength_ (libs/iovm/source/IoFile.c) returns UArray *, but its error path did:

if (IOSTATE->errorRaised) return IONIL(self);

IONIL(self) expands to IOSTATE->ioNil, an IoObject *. Since UArray is a distinct basekit struct (not a typedef of IoObject), this is a real incompatible-pointer return.

It was also a latent logic + leak bug: both callers (readBufferOfLength_, readStringOfLength_) test the result for NULL to mean "return Nil". The non-NULL ioNil pointer would make a failed read look successful and then get passed to IoSeq_newWithUArray_copy_, and the freshly allocated UArray was leaked.

Fix

Free the buffer and return NULL, matching the existing end-of-file path a few lines below.

I swept the rest of the tree for the same class of incompatible-pointer return; this was the only genuine one (other apparent hits return IoObject-typedef'd types like IoMessage/IoNumber, which are fine).

🤖 Generated with Claude Code

GCC 16 promotes -Wincompatible-pointer-types to an error by default,
which broke the native build (discussion #498). IoFile_readUArrayOfLength_
returns UArray *, but its error path returned IONIL(self) — an IoObject *.

Besides the type mismatch this was also a latent logic/leak bug: both
callers (readBufferOfLength_, readStringOfLength_) test the result for
NULL to mean "return Nil", so the non-NULL ioNil pointer made a failed
read look successful, and the freshly allocated UArray was leaked.

Free the buffer and return NULL, matching the existing end-of-file path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@stevedekorte stevedekorte merged commit 888c8c9 into master Jun 26, 2026
1 check passed
@stevedekorte stevedekorte deleted the fix/gcc16-incompatible-pointer-readUArray branch June 26, 2026 19:01
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.

1 participant