From owner-sc22wg14+sc22wg14-domo2=www.open-std.org@open-std.org  Thu Oct  1 18:59:00 2026
Return-Path: <owner-sc22wg14+sc22wg14-domo2=www.open-std.org@open-std.org>
X-Original-To: sc22wg14-domo2
Delivered-To: sc22wg14-domo2@www.open-std.org
Received: by www.open-std.org (Postfix, from userid 521)
	id 2AA52356E55; Thu,  1 Oct 2026 18:59:00 +0200 (CEST)
Delivered-To: sc22wg14@open-std.org
Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124])
	by www.open-std.org (Postfix) with ESMTP id 965B6356C79
	for <sc22wg14@open-std.org>; Thu,  1 Oct 2026 18:58:58 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
	s=mimecast20190719; t=1790873938;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type;
	bh=wFEVznzR7R6XmpVhSjTsA2CEo9DjM1afAzKdomnInEo=;
	b=IHIXoeSemg5MbSxlFo2TFAL2prCCuFxrrKnco3M8W7nKlhH3SbkLLeO943lXVKvjzxj96m
	Dw+/D3j0rHNjhQaS1ZhU9B5N3FpVbdpGj3yNr42Ct4gXhs8hbTfHlbtPNHk1YYOE+EXckO
	NCYldo0YSSUzBixy6MDgyHrDxqO0RCo=
Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com
 [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS
 (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id
 us-mta-654-6Mu7JTpPOsaBZbKElXbvUw-1; Thu, 01 Oct 2026 12:58:55 -0400
X-MC-Unique: 6Mu7JTpPOsaBZbKElXbvUw-1
X-Mimecast-MFC-AGG-ID: 6Mu7JTpPOsaBZbKElXbvUw_1790873934
Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-5bb78051100so484575e87.3
        for <sc22wg14@open-std.org>; Thu, 01 Oct 2026 09:58:55 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1790873934; x=1791478734;
        h=content-type:mime-version:message-id:subject:to:from:date:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=mCQaSixa8BFabND8TF9kUxRsZLd03vuJaeYlD1KfBME=;
        b=2dAQ0QsysFEf3PMPTP/q/X1ya3GQqr+571V+cfb9gBHXjTtWAN49qWWdRZXgnKZDUS
         PYGg+IWWEbWVYpql8SVeDyyvwOnCIZFh3gp6qrM0ClbNNDjwocyBzJFLRpWmxVKjxZlr
         8Fp8jN+5xbbUbsRlw+BlpL6pAZI/cTGCEpea3xA6CyLTsPOTKfA13SQSR0Foxcmw4/W0
         ZTDcv3oOczSPaKTG/JJgDRgUlR+4nCNbxW+oQLaQpeijNk2aaIKAUMjOuHl4mBJc7TFo
         sT4zlWOfOyEGm8OBbu2xWjC23SDwU/a+yN2MFiLTLrlR8BVDq2X1mt1JoVOAa9CzjSEy
         rZqQ==
X-Gm-Message-State: AFq9FYLw1GMehqzCqNjGBKfIDlDJGGGU7jUj7L9+2McV1UdDOAgOWdpK
	0/gKc4BNPfFU2MXfpRLSYiNo9DQOSunFyEnkijIcqLqY3ATdmfYljtltpWBKkvg8TH6YA+pIjdN
	GyIR9/eXWH6FmCdcpcuHbeAn06pEFIswXuqVngxFAuzq5nRq81JGQowhGTnoDOOiLGMnhM742Sq
	VBzpcGHNoQjZzsg49T87Tq9sbY/ga8/Y0Zh3ZIutu/
X-Gm-Gg: AYBFou15Oq4ukC1nJiapxPcbMELOub9O7eCOr8AIyAPeoAlBLCpBVgBdIjw34XtwD3f
	WtJVtje8Kqr61xHB/UDebAuKzGBeGcayX5/0IkQ8uL0DX8DP9Rat7sN/BYluVMAifeBBd09XbbQ
	hArsrhU7ZtNB+JIvQHAVMuI2dSJxeYaCh/HyxBW1o0Jds0SnBmAEV90aTXfvby/1ilcE39T56+C
	qAggy1ZwQsN6Xfr89AnxlLqR5E+jnt2uwFR4/S5rkDkTZIVvRiVRyK1wRn4ntMWNT8qcQ66COog
	6sDitFkO4K5/PCg+G17zHuI2apPgh0kU/ThgqxV5Tgq+bLB83KQv/vdSRdPh/UVt2zKa5oZNpAL
	cVn0YVWrV+eEkX0EYR3D+nxsMFAWOcpYEPwwvaNk=
X-Received: by 2002:a05:6512:6681:10b0:5b8:9a42:ccb0 with SMTP id 2adb3069b0e04-5ba405ea447mr1769013e87.18.1790873933703;
        Thu, 01 Oct 2026 09:58:53 -0700 (PDT)
X-Received: by 2002:a05:6512:6681:10b0:5b8:9a42:ccb0 with SMTP id 2adb3069b0e04-5ba405ea447mr1769003e87.18.1790873933153;
        Thu, 01 Oct 2026 09:58:53 -0700 (PDT)
Received: from digraph.polyomino.org.uk (digraph.polyomino.org.uk. [81.187.227.50])
        by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5bb7c7abcbesm17818e87.63.2026.10.01.09.58.50
        for <sc22wg14@open-std.org>
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 01 Oct 2026 09:58:51 -0700 (PDT)
Received: from jsm28 (helo=localhost)
	by digraph.polyomino.org.uk with local-esmtp (Exim 4.98.2)
	(envelope-from <josmyers@redhat.com>)
	id 1xCK7N-00000000Xo0-04z0
	for sc22wg14@open-std.org;
	Thu, 01 Oct 2026 16:58:49 +0000
Date: Thu, 1 Oct 2026 16:58:49 +0000 (UTC)
From: Joseph Myers <josmyers@redhat.com>
To: sc22wg14@open-std.org
Subject: N3947 nextafter argument conversions
Message-ID: <7c35b8ce-6066-ae99-a969-03e30461f305@redhat.com>
MIME-Version: 1.0
X-Mimecast-Spam-Score: 0
X-Mimecast-MFC-PROC-ID: a32XjDBGugOj5taGMqkwSqyQdD5h9ufn6OnbtPxP3Jc_1790873934
X-Mimecast-Originator: redhat.com
Content-Type: multipart/mixed; boundary="-1152306461-1811445089-1790873929=:120673"
Sender: owner-sc22wg14@open-std.org
Precedence: bulk

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
---1152306461-1811445089-1790873929=:120673
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8BIT

N3947 proposes removing wording about conversion of arguments of nextafter 
to the return type of the function, because a literal reading of the 
nexttoward description "equivalent to the nextafter functions except" 
could be taken as meaning that the long double argument to nexttoward also 
gets converted to the return type.

I think there are two things that "converted to the return type of the 
function" could be taken to refer to.

* One is about conversion such as happens implicitly by argument passing.  
While the Note being changed says "even by a macro implementation of the 
function", I think such an implicit conversion should be required for 
*all* standard library functions.  We seem to be lacking a clear 
specification in 7.1.4 about exactly what semantics macro implementations 
must share with the underlying function; although it is said that 
arguments evaluate only once "so it is generally safe to use arbitrary 
expressions as arguments" and "may be invoked in an expression anywhere a 
function with a compatible return type could be called", the statement 
"However, such macros can sometimes not contain the sequence points that 
the corresponding function calls do." is only a footnote (so not 
normative) and there seems to be no specification about which other 
semantics, such as argument conversion, do or do not apply.  I'd say 
"arbitrary expressions" implies any expression that would be valid for the 
underlying function, but does it also imply the conversions coming from 
the prototype?

* The other is about evaluation formats with extra range or precision.  
As evidence that this was what was intended originally by the wording for 
nextafter (apart from the argument that the first point about applies to 
all functions), see the C99 Rationale, which says "The nextafter functions 
can be employed to obtain next values in a particular format. For example, 
nextafterf(x, y) will return the next float value after (float)x in the 
direction of (float)y regardless of the evaluation method." - thus, 
talking explicitly about casts (which remove extra range and precision) 
and evaluation formats.

Now, casts remove extra range and precision.  Assignment removes extra 
range and precision.  But it's not necessarily the case that argument 
passing and return do so; although they are conversion as if by 
assignment, they are not actually assignments.  It's explicitly specified 
that "The value of FLT_EVAL_METHOD does not characterize values returned 
by function calls (see 6.8.7.5, F.6)."; it's only F.6 (footnote 398) that 
says extra range and precision is removed by return, and even there, it's 
implementation-defined what happens when the formats of the types are the 
same (see F.3 paragraph 4).  By contrast, in 6.8.7.5, footnote 165 says 
"The representation of floating-point values can have wider range or 
precision than implied by the type; a cast can be used to remove this 
extra range and precision.".

For an implementation of Annex F, F.3 paragraph 12 says "ISO/IEC 60559 
requires operations with specified operand and result formats. Therefore, 
math functions that are bound to ISO/IEC 60559 operations (see Table F.1) 
shall remove any extra range and precision from arguments or results.".  
Unfortunately it's not clear if that helps here since nextafter isn't 
bound to a current ISO/IEC 60559 operation in that table; rather, it's 
"the nextafter function recommended in the Appendix to (superseded) IEC 
60559:1989 (but with a minor change to better handle signed zeros).".

So I think the real questions underlying this nextafter wording are:

1. For conversions between different types, is implicit conversion 
required for macro implementations of all standard library functions?  If 
not, it probably should be.

2. May argument passing pass values with extra range and precision, like 
return, since it's a conversion as if by assignment not actually an 
assignment?  There are two cases, (a) without Annex F and (b) with Annex 
F.  In case (b), I think it's only possible there might be extra range 
and precision when the two types (same or different; for example, they 
could be float and _Float32) have the same format, because otherwise the 
binding to convertFormat ensures extra range and precision is removed.

3. If argument passing might sometimes use extra range and precision, how 
do we ensure that remains disallowed for nextafter (and for nexttoward, 
just with a different type for the second argument) without suggesting the 
second argument of nexttoward gets converted to a type other than long 
double?

4. Does F.3 paragraph 12 apply to functions described in terms of 
operations from old versions of ISO/IEC 60559 and related standards?  
Even if nextafter and nexttoward are resolved in the main body of the 
standard, this still matters for fmin, fmax and nearbyint (nearbyint being 
defined in terms of "the Appendix to (superseded) ANSI/IEEE 854–1987").  
Must extra range and precision be removed from arguments to fmin, fmax 
and nearbyint by an implementation of Annex F?

5. Editorial: we've ended up with both "extra" and "excess" range and 
precision references in the standard and should probably make the 
terminology uniform.

-- 
Joseph S. Myers
josmyers@redhat.com

---1152306461-1811445089-1790873929=:120673--

