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-05-21 15:00 |
| Reporter | lygstate | Assigned To | |||
| Priority | normal | Severity | Editorial | Type | Enhancement Request |
| Status | New | Resolution | Open | ||
| Name | Yonggang Luo | ||||
| Organization | |||||
| User Reference | |||||
| Section | https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_types.h.html#tag_14_70 | ||||
| Page Number | 0 | ||||
| Line Number | 0 | ||||
| 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 | ||||