Repository navigation
fix: declare external scanner create functions with (void) - #311
Merged
calebdw merged 1 commit intoNov 19, 2026
Merged
Conversation
The external scanner create functions were defined with an empty parameter list, which in C before C23 is a non-prototype declaration. The tree-sitter runtime calls them through a void *(*)(void) pointer. The call is valid C17, but Clang's -fsanitize=function (part of -fsanitize=undefined since Clang 17) compares the exact function types and reports: runtime error: call to function tree_sitter_php_external_scanner_create through pointer to incorrect function type 'void *(*)(void)' Using (void) makes the definitions real prototypes, matching the pointer type and the tree-sitter documentation for external scanners. It also silences -Wstrict-prototypes.
calebdw
approved these changes
Nov 19, 2026
Collaborator
|
thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
tree_sitter_php_external_scanner_create()andtree_sitter_php_only_external_scanner_create()are defined with an empty parameter list. Before C23 that is a non-prototype declaration, while the runtime calls them through avoid *(*)(void)pointer.This is valid C17, but Clang's
-fsanitize=function(enabled by-fsanitize=undefinedsince Clang 17) compares the exact types and reports:Any project that embeds the grammar and runs its tests under UBSan with Clang hits this (seen with Clang 21 on Ubuntu and Clang 23 on macOS).
Change
Use
(void)in both wrappers and inexternal_scanner_createincommon/scanner.h. No behavior change; this matches the external scanner signatures in the tree-sitter docs and silences-Wstrict-prototypes.Testing
-fsanitize=address,undefined: the runtime error is gone and its parsing tests pass.clang -std=c17 -Wstrict-prototypesonphp/src/scanner.c: 2 warnings before, 0 after.