[Bug 281768] [PATCH] stdio.h: don't expose rsize_t unless __EXT1_VISIBLE
Date: Mon, 30 Sep 2024 01:36:40 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=281768
Bug ID: 281768
Summary: [PATCH] stdio.h: don't expose rsize_t unless
__EXT1_VISIBLE
Product: Base System
Version: CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: standards
Assignee: standards@FreeBSD.org
Reporter: gperciva@tarsnap.com
Created attachment 253899
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=253899&action=edit
stdio.h: don't expose rsize_t unless __EXT1_VISIBLE
<stdio.h> should not unconditionally declare rsize_t; this patch fixes that by
wrapping the typedef inside an `#if __EXT1_VISIBLE`, which is how it's done in
<stddef.h>, <stdlib.h>, and <string.h>.
In C99, rsize_t is not a reserved identifier. (POSIX reserves *_t, but in C99,
there's no global *_t reservation; only int*_t and uint*_t in <stdint.h>.)
As such, technically speaking this should compile:
```
$ cat conflict.c
#include <stdio.h>
typedef int rsize_t;
$ c99 -c conflict.c
conflict.c:2:13: error: typedef redefinition with different types ('int' vs
'size_t' (aka 'unsigned long'))
2 | typedef int rsize_t;
| ^
/usr/include/stdio.h:55:16: note: previous definition is here
55 | typedef size_t rsize_t;
| ^
1 error generated.
```
Related history:
- Problematic commit:
https://github.com/freebsd/freebsd-src/commit/c13559d31e90a8c405771be36ab9ccfa41d4ebd6
- Good example: adding `typedef size_t rsize_t;` to <stddef.h> and <stdlib.h>
as part of memset_s addition
https://reviews.freebsd.org/D9903
--
You are receiving this mail because:
You are the assignee for the bug.