View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001937 | 1003.1(2024)/Issue8 | System Interfaces | public | 2025-07-21 16:02 | 2025-08-14 15:19 |
Reporter | dalias | Assigned To | |||
Priority | normal | Severity | Editorial | Type | Error |
Status | Resolved | Resolution | Accepted As Marked | ||
Name | Rich Felker | ||||
Organization | musl libc | ||||
User Reference | |||||
Section | tsearch | ||||
Page Number | unknown | ||||
Line Number | unknown | ||||
Interp Status | --- | ||||
Final Accepted Text | 0001937:0007231 | ||||
Summary | 0001937: Undefined behavior in tsearch EXAMPLES text | ||||
Description | The usage examples for the tsearch.h interfaces contain multiple expressions of the form: *(struct element **)node This accesses the object pointed-to by node with a type (struct element *) not matching its effective type (void *, aka posix_tnode), thereby having undefined behavior. The intent is to load the value pointed to by node, and interpret it as a pointer to struct element. This can be done correctly as: (struct element *)*node This accesses the pointed-to object with the correct type (posix_tnode), then converts the accessed value, rather than trying to access an object with the wrong type. | ||||
Desired Action | Replace all 4 instances of: *(struct element **) in EXAMPLES with: (struct element *)* | ||||
Tags | tc1-2024 |
|
Oops, it looks like I accidentally filed this for issue 7. Can it be moved to issue 8 (since it's worded relative to issue 8 and still relevant) or should I re-file for issue 8? |
|
And I was mistakenly thinking posix_tnode was defined as void *, but since it's defined as void, the correct form should be: (struct element *)*(void **) |
|
The fourth use is not quite the same as it involves const. Givenconst posix_tnode *ptris this right: const struct element *p = (const struct element *)*(void **) ptr;or should there be a const somewhere in the (void **) as well? |
|
Replace the 1st (line 73286) and 3rd (line 73295) instances of:*(struct element **) in EXAMPLES with: *(void **) Line 73288 Replace the instance of: (*(struct element **)node)->count++; with: ((struct element *)*(void **)node)->count++; Line 73321 Replace the instance of: const struct element *p = *(const struct element **) ptr; with: const struct element *p = *(void **) ptr; |
Date Modified | Username | Field | Change |
---|---|---|---|
2025-07-21 16:02 | dalias | New Issue | |
2025-07-21 16:04 | dalias | Note Added: 0007225 | |
2025-07-21 22:48 | dalias | Note Added: 0007226 | |
2025-07-22 09:26 | geoffclare | Project | 1003.1(2016/18)/Issue7+TC2 => 1003.1(2024)/Issue8 |
2025-07-22 10:01 | geoffclare | Note Added: 0007227 | |
2025-07-24 16:42 | geoffclare | Note Added: 0007231 | |
2025-08-14 15:18 | geoffclare | Note Edited: 0007231 | |
2025-08-14 15:19 | geoffclare | Status | New => Resolved |
2025-08-14 15:19 | geoffclare | Resolution | Open => Accepted As Marked |
2025-08-14 15:19 | geoffclare | Interp Status | => --- |
2025-08-14 15:19 | geoffclare | Final Accepted Text | => 0001937:0007231 |
2025-08-14 15:19 | geoffclare | Tag Attached: tc1-2024 |