NetBSD Problem Report #58752

From www@netbsd.org  Sun Oct 13 21:03:01 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 085F31A923B
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 13 Oct 2024 21:03:01 +0000 (UTC)
Message-Id: <20241013210259.D55421A923D@mollari.NetBSD.org>
Date: Sun, 13 Oct 2024 21:02:59 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: various header files test _*_SOURCE macros but don't include sys/featuretest.h
X-Send-Pr-Version: www-1.0

>Number:         58752
>Category:       lib
>Synopsis:       various header files test _*_SOURCE macros but don't include sys/featuretest.h
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 13 21:05:00 +0000 2024
>Closed-Date:    Sat Nov 02 03:26:32 +0000 2024
>Last-Modified:  Sat Nov 02 03:35:01 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, 10, 9
>Organization:
The _NETBSD_SOURCE Featuration
>Environment:
>Description:
<uchar.h> tests _NETBSD_SOURCE, _POSIX_C_SOURCE, and _ISOC23_SOURCE, but doesn't include <sys/featuretest.h> to get the defaults or default implications.

Several other candidate header files match in an amd64 install:

/usr/include/amd64/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
/usr/include/arpa/nameser.h -- N/A, nonstandard BIND resolver API
/usr/include/event2/event-config.h -- N/A, nonstandard libevent API
/usr/include/g++/bits/c++locale.h -- N/A, reference is in comment only
/usr/include/i386/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
/usr/include/langinfo.h
/usr/include/machine/mcontext.h -- N/A, symlink to amd64/mcontext.h
/usr/include/monetary.h
/usr/include/nl_types.h
/usr/include/regex.h
/usr/include/rmt.h -- N/A, _FORTIFY_SOURCE
/usr/include/rump/rumpuser_port.h -- N/A, defines _GNU_SOURCE on GNU systems
/usr/include/ssp/ssp.h -- N/A, _FORTIFY_SOURCE
/usr/include/sys/common_limits.h
/usr/include/sys/featuretest.h -- N/A (duh)
/usr/include/sys/ttycom.h
/usr/include/uchar.h -- fixed
/usr/include/zconf.h -- N/A, _LARGEFILE64_SOURCE (not used in NetBSD)
/usr/include/zlib.h

Files under src matching this:

include/arpa/nameser.h -- N/A, nonstandard BIND resolver API
include/langinfo.h
include/monetary.h
include/nl_types.h
include/regex.h
include/rmt.h -- N/A, _FORTIFY_SOURCE
include/ssp/ssp.h -- N/A, _FORTIFY_SOURCE
include/uchar.h -- fixed
sys/arch/alpha/include/fenv.h
sys/arch/alpha/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/arch/amd64/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/arch/arm/include/float.h
sys/arch/arm/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/arch/hppa/include/float.h
sys/arch/hppa/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/arch/i386/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/arch/ia64/include/fenv.h
sys/arch/ia64/include/float.h -- N/A, commented out
sys/arch/ia64/include/limits.h
sys/arch/ia64/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/arch/m68k/include/fenv.h
sys/arch/m68k/include/float.h
sys/arch/m68k/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/arch/mips/include/fenv.h
sys/arch/mips/include/float.h
sys/arch/mips/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/arch/or1k/include/float.h
sys/arch/or1k/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/arch/powerpc/include/fenv.h
sys/arch/powerpc/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/arch/riscv/include/float.h
sys/arch/riscv/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/arch/sh3/include/fenv.h
sys/arch/sh3/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/arch/sparc/include/float.h
sys/arch/sparc/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/arch/vax/include/math.h
sys/arch/vax/include/mcontext.h -- N/A, private _*_SOURCE (rtld, libc, libpthread)
sys/sys/common_limits.h
sys/sys/epoll.h
sys/sys/featuretest.h
sys/sys/ttycom.h

(I have not reviewed all of these to see if the _*_SOURCE is relevant.  For example, sys/featuretest.h isn't needed for _FORTIFY_SOURCE at the moment as far as I know.)
>How-To-Repeat:
Try to use <uchar.h> without defining any feature macros, so that the default (_NETBSD_SOURCE) should be implied:

#include <uchar.h>

char8_t x;
>Fix:
Yes, please!

>Release-Note:

>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58752 CVS commit: src/include
Date: Sun, 13 Oct 2024 21:32:23 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Sun Oct 13 21:32:23 UTC 2024

 Modified Files:
 	src/include: uchar.h

 Log Message:
 uchar.h: Include <sys/featuretest.h> before testing _*_SOURCE.

 PR lib/58752: various header files test _*_SOURCE macros but don't
 include sys/featuretest.h

 PR lib/52374: <uchar.h> missing


 To generate a diff of this commit:
 cvs rdiff -u -r1.3 -r1.4 src/include/uchar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58752 CVS commit: src/tests/lib/libc/locale
Date: Sun, 13 Oct 2024 23:21:30 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Sun Oct 13 23:21:30 UTC 2024

 Modified Files:
 	src/tests/lib/libc/locale: t_uchar.c

 Log Message:
 tests/lib/libc/locale/t_uchar: Test for char8_t, mbrtoc8, c8rtomb.

 PR lib/58752: various header files test _*_SOURCE macros but don't
 include sys/featuretest.h

 PR lib/52374: <uchar.h> missing


 To generate a diff of this commit:
 cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/locale/t_uchar.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58752 CVS commit: src
Date: Wed, 30 Oct 2024 15:56:12 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Wed Oct 30 15:56:12 UTC 2024

 Modified Files:
 	src/include: langinfo.h monetary.h nl_types.h regex.h
 	src/sys/arch/alpha/include: fenv.h
 	src/sys/arch/arm/include: float.h
 	src/sys/arch/hppa/include: float.h
 	src/sys/arch/ia64/include: fenv.h limits.h
 	src/sys/arch/m68k/include: fenv.h float.h
 	src/sys/arch/mips/include: fenv.h float.h
 	src/sys/arch/or1k/include: float.h
 	src/sys/arch/powerpc/include: fenv.h
 	src/sys/arch/riscv/include: float.h
 	src/sys/arch/sh3/include: fenv.h
 	src/sys/arch/sparc/include: float.h
 	src/sys/arch/vax/include: math.h
 	src/sys/sys: common_limits.h epoll.h ttycom.h

 Log Message:
 Sprinkle <sys/featuretest.h> where _*_SOURCE macros are consulted.

 Otherwise, the feature tests might come out wrong.  For example,
 header files that check for _NETBSD_SOURCE won't get the default when
 no other _*_SOURCE macros are defined; header files that check for
 _POSIX_C_SOURCE might miss _XOPEN_SOURCE, which is supposed to imply
 a corresponding _POSIX_C_SOURCE.

 PR lib/58752: various header files test _*_SOURCE macros but don't
 include sys/featuretest.h


 To generate a diff of this commit:
 cvs rdiff -u -r1.10 -r1.11 src/include/langinfo.h
 cvs rdiff -u -r1.4 -r1.5 src/include/monetary.h
 cvs rdiff -u -r1.13 -r1.14 src/include/nl_types.h
 cvs rdiff -u -r1.16 -r1.17 src/include/regex.h
 cvs rdiff -u -r1.3 -r1.4 src/sys/arch/alpha/include/fenv.h
 cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/include/float.h
 cvs rdiff -u -r1.8 -r1.9 src/sys/arch/hppa/include/float.h
 cvs rdiff -u -r1.3 -r1.4 src/sys/arch/ia64/include/fenv.h
 cvs rdiff -u -r1.10 -r1.11 src/sys/arch/ia64/include/limits.h
 cvs rdiff -u -r1.9 -r1.10 src/sys/arch/m68k/include/fenv.h
 cvs rdiff -u -r1.23 -r1.24 src/sys/arch/m68k/include/float.h
 cvs rdiff -u -r1.6 -r1.7 src/sys/arch/mips/include/fenv.h
 cvs rdiff -u -r1.19 -r1.20 src/sys/arch/mips/include/float.h
 cvs rdiff -u -r1.1 -r1.2 src/sys/arch/or1k/include/float.h
 cvs rdiff -u -r1.7 -r1.8 src/sys/arch/powerpc/include/fenv.h
 cvs rdiff -u -r1.1 -r1.2 src/sys/arch/riscv/include/float.h
 cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sh3/include/fenv.h
 cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sparc/include/float.h
 cvs rdiff -u -r1.9 -r1.10 src/sys/arch/vax/include/math.h
 cvs rdiff -u -r1.3 -r1.4 src/sys/sys/common_limits.h
 cvs rdiff -u -r1.2 -r1.3 src/sys/sys/epoll.h
 cvs rdiff -u -r1.22 -r1.23 src/sys/sys/ttycom.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Sat, 02 Nov 2024 03:26:32 +0000
State-Changed-Why:
fixed in HEAD, not worth pullup because packages are built against 10.0/9.0


From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58752 CVS commit: src/include
Date: Sat, 2 Nov 2024 03:21:42 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Sat Nov  2 03:21:42 UTC 2024

 Modified Files:
 	src/include: util.h

 Log Message:
 <util.h>: Need <sys/featuretest.h> for _POSIX_C_SOURCE.

 PR lib/58752: various header files test _*_SOURCE macros but don't
 include sys/featuretest.h


 To generate a diff of this commit:
 cvs rdiff -u -r1.69 -r1.70 src/include/util.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.