Skip to content

[Docs] Improve function pointer docs#26667

Open
kripken wants to merge 1 commit intoemscripten-core:mainfrom
kripken:fp.docs
Open

[Docs] Improve function pointer docs#26667
kripken wants to merge 1 commit intoemscripten-core:mainfrom
kripken:fp.docs

Conversation

@kripken
Copy link
Copy Markdown
Member

@kripken kripken commented Apr 10, 2026

The message mentioned was for asm.js, not wasm.

Also mention the clang flag for warnings on casts in another place.

@kripken kripken requested a review from sbc100 April 10, 2026 19:08
Function pointer casts can cause function pointer calls to fail.

Function pointers must be called with the correct type: it is undefined behavior in C and C++ to cast a function pointer to another type and call it that way. This does work in most native platforms, however, despite it being UB, but in Wasm it can fail. In that case, you may see an ``abort(10)`` or some other number, and if assertions are on you may see a message with details that start with
Function pointers must be called with the correct type: it is undefined behavior in C and C++ to cast a function pointer to another type and call it that way. This does work in most native platforms, however, despite it being UB, but in Wasm it can fail. In that case, you may see an error like this:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C/C++

index will call this function, which simply calls ``abort()``.
If you get

::
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you combine there lines. e.g. If you get ::`?

RuntimeError: null function or function signature mismatch

(or, in certain build types, an ``abort()`` or an error of "incorrect function
pointer"), the problem is that a proper function pointer was not found in the
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.. the problem is that a function of the correct type was not found in the ..

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