View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001981 | 1003.1(2024)/Issue8 | Base Definitions and Headers | public | 2026-05-21 15:00 | 2026-06-01 03:23 |
| Reporter | lygstate | Assigned To | msbrown | ||
| Priority | normal | Severity | Editorial | Type | Enhancement Request |
| Status | Resolution Proposed | Resolution | Accepted As Marked | ||
| Name | Yonggang Luo | ||||
| Organization | |||||
| User Reference | |||||
| Section | https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_types.h.html#tag_14_70 | ||||
| Page Number | 426 | ||||
| Line Number | 14835-14836 | ||||
| Interp Status | --- | ||||
| Final Accepted Text | |||||
| Summary | 0001981: Request to define ssize_t as the signed version of size_t | ||||
| Description | Currently ssize_t is defined as: ssize_t shall be signed integer types. The type ssize_t shall be capable of storing values at least in the range [-1, {SSIZE_MAX}]. But the sizeof ssize_t is not explicitly defined. And for glibc,musl,cygwin newlib, they all defined that sizeof(ssize_t)=== sizeof(size_t) And maybe because the sizeof ssize_t is not defined clearly. clang did not defined the sizeof of ssize_t well: https://github.com/llvm/llvm-project/issues/198975 The glibc defined the sizeof ssize_t to be equal to size_t by the following codes: #if __WORDSIZE == 32 # define __SWORD_TYPE int #else # define __SWORD_TYPE long int #endif at https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/bits/types.h;h=33b582a8eabf09aadc093658db82353c288590d2;hb=HEAD#l118 #define __SSIZE_T_TYPE __SWORD_TYPE at https://sourceware.org/git/?p=glibc.git;a=blob;f=bits/typesizes.h;h=466dd36681a7364952e49b73067d66174543cffd;hb=HEAD#l60 __STD_TYPE __SSIZE_T_TYPE __ssize_t; /* Type of a byte count, or error. */ at https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/bits/types.h;h=33b582a8eabf09aadc093658db82353c288590d2;hb=HEAD#l194 #ifndef __ssize_t_defined typedef __ssize_t ssize_t; # define __ssize_t_defined #endif at https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/sys/types.h;h=2b524761748fc2e0576e3b86fd5558e8a9ebcb18;hb=HEAD#l108 And the document of __WORDSIZE is: /* Size in bits of the 'long int' and pointer types. */ #define __WORDSIZE at https://sourceware.org/git/?p=glibc.git;a=blob;f=bits/wordsize.h;h=53013a9275c7c81eccb0356ab956eb2688bcf512;hb=HEAD#l7 So basically glibc is already ensure ssize_t is the same size as size_t. Even thoug the command "/* Size in bits of the 'long int' and pointer types. */" is a bit mis-leading. As sizeof pointer will not always have the same size as size_t. | ||||
| Desired Action | define sizeof ssize_t to be sizeof size_t, | ||||
| Tags | issue8, issue9, size_t, ssize_t | ||||
|
|
There is also a sizeable discussion here https://sourceware.org/pipermail/libc-alpha/2026-May/177557.html |
|
|
The committee has discussed this issue, and believes that the following should be the proposed resolution for inclusion in Issue 9 (as it is not in scope for an Issue 8 corrigendum): Proposal: At page 426 after line 14863 add new bullet: ssize_t shall be a signed integer type of the same size as size_t. |
|
|
Re https://www.austingroupbugs.net/view.php?id=1981#c7433 I suggest change that to: > ssize_t shall be a signed integer type of the same _rank_ as size_t. Rank is a defined concept in C. Even if some integer types are of the same size as another, they may not necessarily be of the same rank, and even in some very hypothetical cases, might have different amount of padding bits. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-05-21 15:00 | lygstate | New Issue | |
| 2026-05-21 15:00 | lygstate | Tag Attached: issue8 | |
| 2026-05-21 15:00 | lygstate | Tag Attached: issue9 | |
| 2026-05-21 15:00 | lygstate | Tag Attached: size_t | |
| 2026-05-21 15:00 | lygstate | Tag Attached: ssize_t | |
| 2026-05-28 15:03 | msbrown | Note Added: 0007432 | |
| 2026-05-28 15:07 | msbrown | Page Number | 0 => 426 |
| 2026-05-28 15:07 | msbrown | Line Number | 0 => 14835-14836 |
| 2026-05-28 15:07 | msbrown | Interp Status | => --- |
| 2026-05-28 16:00 | msbrown | Note Added: 0007433 | |
| 2026-05-28 16:01 | msbrown | Assigned To | => msbrown |
| 2026-05-28 16:01 | msbrown | Status | New => Resolution Proposed |
| 2026-05-28 16:01 | msbrown | Resolution | Open => Accepted As Marked |
| 2026-06-01 03:23 | dannyniu | Note Added: 0007435 |