tursodatabase / tursodatabase/libsql
undefined behivior (in terms of the C standard) in libsql-sqlite3/src/vectorfloat16.c
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17.2k
- Forks
- 531
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
I am not sure if this is intentional or not but if it is intentional I would expect some sort of comment documenting why this is the chosen implementation.
so in line 74 IN https://github.com/tursodatabase/libsql/blob/main/libsql-sqlite3/src/vectorfloat16.c#L74
there is a deference of an int pointer as float. In ansi C that's undefined behavior because it breaks strict aliasing.
The situation can be mostly remedied for c99+ by using a union instead of just a u32.
however I dont really have a clean solution for purely ansi C.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting line 74 of libsql-sqlite3/src/vectorfloat16.c and the surrounding implementation to confirm how the int pointer is interpreted as a float. Check the applicable C-standard and project compatibility requirements; done means the strict-aliasing behavior is resolved or its intentional rationale is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100