Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #163035
| From | James Kuyper <jameskuyper@alumni.caltech.edu> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: #include <stdint.h> |
| Date | 2021-10-06 17:40 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <sjl53p$8us$1@dont-email.me> (permalink) |
| References | <sa5vrs$7d3$1@dont-email.me> <87wnqxxoe3.fsf@nosuchdomain.example.com> <86bl7vb24m.fsf@linuxsc.com> <874kdnw20s.fsf@nosuchdomain.example.com> <sjkj8l$e7e$1@dont-email.me> |
On 10/6/21 12:35 PM, Andrey Tarasevich wrote: > On 6/24/2021 11:28 AM, Keith Thompson wrote: >> >> My reading of the standard is that that's certainly the intent, but >> it's not quite stated explicitly. >> > > Yes, it does. The intent of 6.2.5/9 is, among other things, is to > postulate interchangeability of values of corresponding signed-unsigned > types as function arguments. In several locations, the standard says "The same representation and alignment requirements are meant to imply interchangeability as arguments to functions, return values from functions, and members of unions." There's several problems with that statement. Firstly, "are meant to imply" is weasel-wording. It could have said, more simply and forcefully, "implies". Secondly, the implication doesn't hold up under close examination. For instance, unsigned and signed arguments with the same alignment and same representation for positive values of the signed type could still be passed by different methods as arguments or return values, which would prevent them from being interchangeable. Finally, that wording only appears in informative footnotes, not in normative text. After raising this issue many times over a couple of decades, I finally got confirmation from Larry Jones in 2011 (at that time, secretary of the committee) that use of "are meant to imply" rather than "implies" was deliberate, because it was in fact understood that no such implication was correct. He also confirmed that the non-normative nature of that text was also deliberate - the committee did NOT want to mandate that the types be interchangeable, only to recommend that they be made interchangeable. > No special remarks of any kind are made about variadic functions, which > immediately closes the matter. No need to dig deeper and involve > `va_arg` or anything else. In C2011, the descriptions of the printf() and scanf() family of functions contained one notable difference from the corresponding general requirements for functions with variable arguments: "If any argument is not the correct type for the corresponding conversion specification, the behavior is undefined.". An implementation of C2011 could therefore have provided a conforming extension to the <va_args.h> facilities, allowing you to determine the type of the argument corresponding to each parameter,and the implementations of those functions could make use of that information to fail in some fashion when the argument's type is not correct. Such an implementation would not violate any requirement of C2011. In n2596.pdf, the latest draft of the next version that I have access to, that wording has been replaced: "fprintf shall behave as if it uses va_arg with a type argument naming the type resulting from applying the default argument promotions to the type corresponding to the conversion specification and then converting the result of the va_arg expansion to the type corresponding to the conversion specification." This indicates that the committee acknowledges the validity of that complaint, and has resolved it in a way that's not compatible with the hypothetical implementation I've described above.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
#include <stdint.h> SIMON <invalid@invalid.invalid> - 2021-06-13 23:08 +0100
Re: #include <stdint.h> Bart <bc@freeuk.com> - 2021-06-13 23:27 +0100
Re: #include <stdint.h> Bart <bc@freeuk.com> - 2021-06-13 23:57 +0100
Re: #include <stdint.h> Philipp Klaus Krause <pkk@spth.de> - 2021-06-14 09:03 +0200
Re: #include <stdint.h> Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-06-14 01:23 -0700
Re: #include <stdint.h> Philipp Klaus Krause <pkk@spth.de> - 2021-06-14 12:31 +0200
Re: #include <stdint.h> Bart <bc@freeuk.com> - 2021-06-14 11:54 +0100
Re: #include <stdint.h> James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-06-13 18:34 -0400
Re: #include <stdint.h> Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-06-13 23:34 +0100
Re: #include <stdint.h> Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-06-13 17:48 -0700
Re: #include <stdint.h> Philipp Klaus Krause <pkk@spth.de> - 2021-06-14 09:09 +0200
Re: #include <stdint.h> Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-06-14 01:24 -0700
Re: #include <stdint.h> Philipp Klaus Krause <pkk@spth.de> - 2021-06-14 12:30 +0200
Re: #include <stdint.h> Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-06-24 10:31 -0700
Re: #include <stdint.h> Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-06-24 11:28 -0700
Re: #include <stdint.h> Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-07-11 02:49 -0700
Re: #include <stdint.h> Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-07-11 15:30 -0700
Re: #include <stdint.h> Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-07-16 03:33 -0700
Re: #include <stdint.h> Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-07-16 12:31 -0700
Re: #include <stdint.h> Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-09-30 07:07 -0700
Re: #include <stdint.h> Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-30 08:42 -0700
Re: #include <stdint.h> Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-10-06 03:55 -0700
Re: #include <stdint.h> Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-10-06 07:06 -0700
Re: #include <stdint.h> James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-06 11:47 -0400
Re: #include <stdint.h> Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-10-06 09:35 -0700
Re: #include <stdint.h> Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-10-06 10:06 -0700
Re: #include <stdint.h> James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-06 17:40 -0400
Re: #include <stdint.h> Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-06 22:14 +0000
Re: #include <stdint.h> James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-06 20:06 -0400
Re: #include <stdint.h> Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-07 02:15 +0000
Re: #include <stdint.h> Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-06-24 22:34 +0100
Re: #include <stdint.h> Öö Tiib <ootiib@hot.ee> - 2021-06-24 15:01 -0700
Re: #include <stdint.h> Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-06-24 15:26 -0700
Re: #include <stdint.h> Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-07-11 02:14 -0700
csiph-web