NetBSD Problem Report #60389

From www@netbsd.org  Tue Jun 30 14:58:02 2026
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) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.netbsd.org", Issuer "R13" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 0ED061A923A
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 30 Jun 2026 14:58:02 +0000 (UTC)
Message-Id: <20260630145800.F0A551A9243@mollari.NetBSD.org>
Date: Tue, 30 Jun 2026 14:58:00 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: sys/featuretest.h: _XOPEN_SOURCE=520 fails to imply _POSIX_C_SOURCE=199506L
X-Send-Pr-Version: www-1.0
X-From4GNATS: "campbell+netbsd@mumble.net via gnats" <gnats-admin@NetBSD.org>

>Number:         60389
>Category:       standards
>Synopsis:       sys/featuretest.h: _XOPEN_SOURCE=520 fails to imply _POSIX_C_SOURCE=199506L
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    standards-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 30 15:00:00 +0000 2026
>Last-Modified:  Tue Jun 30 15:05:00 +0000 2026
>Originator:     Taylor R Campbell
>Release:        current, 11, 10, 9, ...
>Organization:
The X/Open BSD Foundation, Inc.
>Environment:
>Description:

	According to Networking Services (XNS), Issue 5.2,
	_XOPEN_SOURCE>=500, not just _XOPEN_SOURCE=500, should imply
	_POSIX_C_SOURCE=199506L:

	> [I]f _XOPEN_SOURCE is set greater than or equal to 500 and
	> _POSIX_SOURCE is defined, or _POSIX_C_SOURCE is set greater
	> than zero and less than or equal to 199506L, the behavior is
	> the same as if only _XOPEN_SOURCE is defined and set greater
	> than or equal to 500.

	https://pubs.opengroup.org/onlinepubs/009619199/chap1.htm#tagcjh_02_03

	But we only define _POSIX_C_SOURCE if _XOPEN_SOURCE=500
	exactly, not >=500.

    148 #elif (_XOPEN_SOURCE - 0) == 500
    149 #define	_POSIX_C_SOURCE	199506L
    150 #endif

	https://nxr.netbsd.org/xref/src/sys/sys/featuretest.h?r=1.13#139

>How-To-Repeat:
#define	_XOPEN_SOURCE	520

#include <sys/featuretest.h>

#ifndef _POSIX_C_SOURCE
#error "fail"
#endif

>Fix:

	Change == to >=.

>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60389 CVS commit: src/sys/sys
Date: Tue, 30 Jun 2026 15:03:08 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Tue Jun 30 15:03:08 UTC 2026

 Modified Files:
 	src/sys/sys: featuretest.h

 Log Message:
 sys/featuretest.h: Make _XOPEN_SOURCE>=500<600 imply POSIX.1-1995.

 PR standards/60389: sys/featuretest.h: _XOPEN_SOURCE=520 fails to
 imply _POSIX_C_SOURCE=199506L


 To generate a diff of this commit:
 cvs rdiff -u -r1.14 -r1.15 src/sys/sys/featuretest.h

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

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.