Greetings! In the man pages, both in Linux and online in multiple sites, the pre and post operators are listed as equal precedence. Two different web sites list them on different levels: http://man7.org/linux/man-pages/man7/precedence.7.html Level 1 https://linux.die.net/man/7/operator Level 2 Linux `man operator` list them on the second level, with right to left associativity: Operator Associativity () [] -> . left to right ! ~ ++ -- + - (type) * & sizeof right to left ... Section "A.2.1 Expressions" of both the C99 & C11 C Draft Standards, list them on different levels: postfix ++ & -- on level 1, with left to right associativity prefix ++ & -- on level 2, with right to left associativity Please review this and all the operator precedence and associativity in the current man page "man operator" against the official C99 & C11 Standards documents, plus the current working draft for the next version of the Standard. Please correct me if I am mistaken. References: Debian Linus Testing, Debian 5.2.9-2 (2019-08-21) x86_64 GNU/Linux Thank you! Cheers! Rick Stanley -- RSI (Rick Stanley, Inc.) (917) 822-7771 www.rsiny.com Computer Systems Consulting Linux & Open Source Specialists
* Rick Stanley <rstanley@rsiny.com>, 2019-09-20, 10:19:
>In the man pages, both in Linux and online in multiple sites, the pre
>and post operators are listed as equal precedence. Two different web
>sites list them on different levels:
>
>http://man7.org/linux/man-pages/man7/precedence.7.html
> Level 1
>
>https://linux.die.net/man/7/operator
> Level 2
FWIW, they are not on different levels. In fact, the operator tables are
identical; the only difference is that the one on linux.die.net is badly
formatted.
In general, I would recommend avoiding linux.die.net. Their manpages are
often out-of-date, but you can't easily tell, because they removed
version information.
--
Jakub Wilk
Hello Rick, On 9/20/19 4:19 PM, Rick Stanley wrote: > Greetings! > > In the man pages, both in Linux and online in multiple sites, the pre > and post operators are listed as equal precedence. Two different web > sites list them on different levels: > > http://man7.org/linux/man-pages/man7/precedence.7.html > Level 1 > > https://linux.die.net/man/7/operator > Level 2 > > Linux `man operator` list them on the second level, with right to left > associativity: > > Operator Associativity > () [] -> . left to right > ! ~ ++ -- + - (type) * & sizeof right to left > ... > > Section "A.2.1 Expressions" of both the C99 & C11 C Draft Standards, > list them on different levels: > > postfix ++ & -- on level 1, with left to right associativity > > prefix ++ & -- on level 2, with right to left associativity So, Harbison & Steele also seems to agree here. Things changed since K&R! I've fixed the page: Operator Associativity Notes () [] -> . ++ -- left to right [1] ! ~ ++ -- + - (type) * & sizeof right to left [2] [...] The following notes provide further information to the above ta‐ ble: [1] The ++ and -- operators at this precedence level are the post‐ fix flavors of the operators. [2] The ++ and -- operators at this precedence level are the pre‐ fix flavors of the operators. > Please review this and all the operator precedence and associativity in > the current man page "man operator" against the official C99 & C11 > Standards documents, plus the current working draft for the next > version of the Standard. You are free to do so. But please don't demand that someone else does so, even if you say "please". Thank you for the bug report! Cheers, Michael -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
Thank you for the update.
I am sorry you have interpreted my request as a demand. It was not
meant or presented as such.
Cheers!
Rick Stanley
On Sun, 2019-09-22 at 23:01 +0200, Michael Kerrisk (man-pages) wrote:
> Hello Rick,
>
> On 9/20/19 4:19 PM, Rick Stanley wrote:
> > Greetings!
> >
> > In the man pages, both in Linux and online in multiple sites, the
> > pre
> > and post operators are listed as equal precedence. Two different
> > web
> > sites list them on different levels:
> >
> > http://man7.org/linux/man-pages/man7/precedence.7.html
> > Level 1
> >
> > https://linux.die.net/man/7/operator
> > Level 2
> >
> > Linux `man operator` list them on the second level, with right to
> > left
> > associativity:
> >
> > Operator Associativity
> > () [] -> . left to right
> > ! ~ ++ -- + - (type) * & sizeof right to left
> > ...
> >
> > Section "A.2.1 Expressions" of both the C99 & C11 C Draft
> > Standards,
> > list them on different levels:
> >
> > postfix ++ & -- on level 1, with left to right associativity
> >
> > prefix ++ & -- on level 2, with right to left associativity
>
> So, Harbison & Steele also seems to agree here. Things changed since
> K&R! I've fixed the page:
>
> Operator Associativity Notes
> () [] -> . ++ -- left to right [1]
> ! ~ ++ -- + - (type) * & sizeof right to left [2]
> [...]
>
> The following notes provide further information to
> the above ta‐
> ble:
>
> [1] The ++ and -- operators at this precedence level are the
> post‐
> fix flavors of the operators.
> [2] The ++ and -- operators at this precedence level are
> the pre‐
> fix flavors of the operators.
>
> > Please review this and all the operator precedence and
> > associativity in
> > the current man page "man operator" against the official C99 & C11
> > Standards documents, plus the current working draft for the next
> > version of the Standard.
>
> You are free to do so. But please don't demand that someone else
> does so, even if you say "please".
>
> Thank you for the bug report!
>
> Cheers,
>
> Michael
>
--
RSI (Rick Stanley, Inc.)
(917) 822-7771
www.rsiny.com
Computer Systems Consulting
Linux & Open Source Specialists
Hello Rick, On 9/23/19 12:50 AM, Rick Stanley wrote: > Thank you for the update. > > I am sorry you have interpreted my request as a demand. It was not > meant or presented as such. Okay. Thanks, Michael > On Sun, 2019-09-22 at 23:01 +0200, Michael Kerrisk (man-pages) wrote: >> Hello Rick, >> >> On 9/20/19 4:19 PM, Rick Stanley wrote: >>> Greetings! >>> >>> In the man pages, both in Linux and online in multiple sites, the >>> pre >>> and post operators are listed as equal precedence. Two different >>> web >>> sites list them on different levels: >>> >>> http://man7.org/linux/man-pages/man7/precedence.7.html >>> Level 1 >>> >>> https://linux.die.net/man/7/operator >>> Level 2 >>> >>> Linux `man operator` list them on the second level, with right to >>> left >>> associativity: >>> >>> Operator Associativity >>> () [] -> . left to right >>> ! ~ ++ -- + - (type) * & sizeof right to left >>> ... >>> >>> Section "A.2.1 Expressions" of both the C99 & C11 C Draft >>> Standards, >>> list them on different levels: >>> >>> postfix ++ & -- on level 1, with left to right associativity >>> >>> prefix ++ & -- on level 2, with right to left associativity >> >> So, Harbison & Steele also seems to agree here. Things changed since >> K&R! I've fixed the page: >> >> Operator Associativity Notes >> () [] -> . ++ -- left to right [1] >> ! ~ ++ -- + - (type) * & sizeof right to left [2] >> [...] >> >> The following notes provide further information to >> the above ta‐ >> ble: >> >> [1] The ++ and -- operators at this precedence level are the >> post‐ >> fix flavors of the operators. >> [2] The ++ and -- operators at this precedence level are >> the pre‐ >> fix flavors of the operators. >> >>> Please review this and all the operator precedence and >>> associativity in >>> the current man page "man operator" against the official C99 & C11 >>> Standards documents, plus the current working draft for the next >>> version of the Standard. >> >> You are free to do so. But please don't demand that someone else >> does so, even if you say "please". >> >> Thank you for the bug report! >> >> Cheers, >> >> Michael >> -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
[-- Attachment #1: Type: text/plain, Size: 2045 bytes --] Hello again! In an effort to bring the current manpage for the C operator table up to the current official Standard, I went back and compared the current manpage operator table against the C99, C11, and C17(18) Draft Standards documents. I do not have access to the Official ISO C Standards documents. I have attached a PDF to document my interpretation of the Standards against the current `man operator` manpage In addition to the pre & postfix ++ & -- operators, I have found one additional change & three additions to the table. Because of these appearing in 6.5.x, and A.2.1, I assume they should be included in the operator table. The current table consists of 15 levels of precedence, C99 adds one new level and C11 adds one more. (type) cast operator change In the current table, the cast operator is listed on level 2 of 15 levels, along with other operators. In C99 this operator has been demoted to a new level inserted between level 2 & 3 of the current level, expanding the table to 16 levels of precedence. I assume the associativity is also "right to left", as is level 2. _Generic operator/keyword addition This new operator/keyword was added in C11. A new top level was created and the remainder of the table has been demoted by one level. default operator/keyword addition This too has been added to the new top level in C11 _Alignof operator/keyword addition This was added to what I refer to as, the new level 3, along with other prefix operators. A new header file has been added to the C11 Standard, stdalign.h (7.15). This #defines alignof to the _Alignof operator/keyword. C11 also #defines alignas to a related keyword, _Alignas. No additional additions or changes to the operator table appear to have been made in the C17(C18) C Standard. Please confirm my observations with the official C Standards documents. This is a polite request, not a demand. Thank you! Rick Stanley -- RSI (Rick Stanley, Inc.) (917) 822-7771 www.rsiny.com Computer Systems Consulting Linux & Open Source Specialists [-- Attachment #2: Operator.pdf --] [-- Type: application/pdf, Size: 17833 bytes --]
Hello Rick, On 9/25/19 5:23 PM, Rick Stanley wrote: > Hello again! > > In an effort to bring the current manpage for the C operator table up > to the current official Standard, I went back and compared the current > manpage operator table against the C99, C11, and C17(18) Draft > Standards documents. I do not have access to the Official ISO C > Standards documents. > > I have attached a PDF to document my interpretation of the Standards > against the current `man operator` manpage > > In addition to the pre & postfix ++ & -- operators, I have found one > additional change & three additions to the table. Because of these > appearing in 6.5.x, and A.2.1, I assume they should be included in the > operator table. > > The current table consists of 15 levels of precedence, C99 adds one new > level and C11 adds one more. > > (type) cast operator change > > In the current table, the cast operator is listed on level 2 of 15 > levels, along with other operators. In C99 this operator has been > demoted to a new level inserted between level 2 & 3 of the current > level, expanding the table to 16 levels of precedence. I assume the > associativity is also "right to left", as is level 2. > > _Generic operator/keyword addition > > This new operator/keyword was added in C11. A new top level was > created and the remainder of the table has been demoted by one level. > > default operator/keyword addition > > This too has been added to the new top level in C11 But, 'default' is not an operator as far as I can tell? (It is part of the '_Generic' construct, not an operator in its own right.) > _Alignof operator/keyword addition > > This was added to what I refer to as, the new level 3, along with other > prefix operators. > > A new header file has been added to the C11 Standard, stdalign.h > (7.15). This #defines alignof to the _Alignof operator/keyword. C11 > also #defines alignas to a related keyword, _Alignas. > > No additional additions or changes to the operator table appear to have > been made in the C17(C18) C Standard. > > Please confirm my observations with the official C Standards documents. > This is a polite request, not a demand. I'm pretty rusty these days on interpreting grammars, but modulo my one point above ('default' should not be there), what you say seems plausible. Would you be comfortable writing a patch, with a cover message that includes much of the text you give above? Thanks, Michael -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
Hello Rick, (Im reflecting more.) On 9/25/19 9:42 PM, Michael Kerrisk (man-pages) wrote: > Hello Rick, > > On 9/25/19 5:23 PM, Rick Stanley wrote: >> Hello again! >> >> In an effort to bring the current manpage for the C operator table up >> to the current official Standard, I went back and compared the current >> manpage operator table against the C99, C11, and C17(18) Draft >> Standards documents. I do not have access to the Official ISO C >> Standards documents. >> >> I have attached a PDF to document my interpretation of the Standards >> against the current `man operator` manpage >> >> In addition to the pre & postfix ++ & -- operators, I have found one >> additional change & three additions to the table. Because of these >> appearing in 6.5.x, and A.2.1, I assume they should be included in the >> operator table. >> >> The current table consists of 15 levels of precedence, C99 adds one new >> level and C11 adds one more. >> >> (type) cast operator change >> >> In the current table, the cast operator is listed on level 2 of 15 >> levels, along with other operators. In C99 this operator has been >> demoted to a new level inserted between level 2 & 3 of the current >> level, expanding the table to 16 levels of precedence. I assume the >> associativity is also "right to left", as is level 2. How do you deduce that this changed between C89/90 and c99? I'm not so convinced now that '(type) cast' changed in precedence. >> _Generic operator/keyword addition >> >> This new operator/keyword was added in C11. A new top level was >> created and the remainder of the table has been demoted by one level. But, is it really an operator? How do you deduce that? >> default operator/keyword addition >> >> This too has been added to the new top level in C11 > > But, 'default' is not an operator as far as I can tell? > (It is part of the '_Generic' construct, not an operator > in its own right.) > >> _Alignof operator/keyword addition This seems clearly correct to me, and I find other sources that agree on this. My general problem is that I find no other sources that confirm your interpretation of the standard that _Generic is a new operator at a new level and that '(type) cast' has changed in precedence. Thanks, Michael -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
Michael:
I have made the assumption that the current manpage operator table was
based on the C89/90 C Standard. This was a bad assumption!
Please throw out what I have sent and I will create a new more detailed
interpretation of the Draft Standards, with more detailed explanation.
I do not work with anything but the Draft Standards documents. (With
one possible additional source. Will explain later)
Thanks!
Rick
--
RSI (Rick Stanley, Inc.)
(917) 822-7771
www.rsiny.com
Computer Consulting
Linux & Open Source Specialist
On Sep 25, 2019, at 4:08 PM, "Michael Kerrisk (man-pages)" <
mtk.manpages@gmail.com> wrote:
> Hello Rick,
>
> (Im reflecting more.)
>
> On 9/25/19 9:42 PM, Michael Kerrisk (man-pages) wrote:
> > Hello Rick,
> >
> > On 9/25/19 5:23 PM, Rick Stanley wrote:
> > > Hello again!
> > >
> > > In an effort to bring the current manpage for the C operator
> > > table up
> > > to the current official Standard, I went back and compared the
> > > current
> > > manpage operator table against the C99, C11, and C17(18) Draft
> > > Standards documents. I do not have access to the Official ISO C
> > > Standards documents.
> > >
> > > I have attached a PDF to document my interpretation of the
> > > Standards
> > > against the current `man operator` manpage
> > >
> > > In addition to the pre & postfix ++ & -- operators, I have found
> > > one
> > > additional change & three additions to the table. Because of
> > > these
> > > appearing in 6.5.x, and A.2.1, I assume they should be included
> > > in the
> > > operator table.
> > >
> > > The current table consists of 15 levels of precedence, C99 adds
> > > one new
> > > level and C11 adds one more.
> > >
> > > (type) cast operator change
> > >
> > > In the current table, the cast operator is listed on level 2 of
> > > 15
> > > levels, along with other operators. In C99 this operator has
> > > been
> > > demoted to a new level inserted between level 2 & 3 of the
> > > current
> > > level, expanding the table to 16 levels of precedence. I assume
> > > the
> > > associativity is also "right to left", as is level 2.
>
> How do you deduce that this changed between C89/90 and c99?
> I'm not so convinced now that '(type) cast' changed in precedence.
>
> > > _Generic operator/keyword addition
> > >
> > > This new operator/keyword was added in C11. A new top level was
> > > created and the remainder of the table has been demoted by one
> > > level.
>
> But, is it really an operator? How do you deduce that?
>
> > > default operator/keyword addition
> > >
> > > This too has been added to the new top level in C11
> >
> > But, 'default' is not an operator as far as I can tell?
> > (It is part of the '_Generic' construct, not an operator
> > in its own right.)
> >
> > > _Alignof operator/keyword addition
>
> This seems clearly correct to me, and I find other sources
> that agree on this.
>
> My general problem is that I find no other sources
> that confirm your interpretation of the standard that _Generic
> is a new operator at a new level and that '(type) cast' has
> changed in precedence.
>
> Thanks,
>
> Michael
>
--
RSI (Rick Stanley, Inc.)
(917) 822-7771
www.rsiny.com
Computer Systems Consulting
Linux & Open Source Specialists
[-- Attachment #1: Type: text/plain, Size: 352 bytes --] Michael: I have gone back and done more research into the updates needed for the operator manpage. Please accept the two files attached to explain my interpretation of the Standards. I look forward to your response. Rick Stanley -- RSI (Rick Stanley, Inc.) (917) 822-7771 www.rsiny.com Computer Systems Consulting Linux & Open Source Specialists [-- Attachment #2: Proposed-operator-manpage-updates.pdf --] [-- Type: application/pdf, Size: 27107 bytes --] [-- Attachment #3: Operator.pdf --] [-- Type: application/pdf, Size: 20632 bytes --]
Michael: I have created a patch to update the current version of the operator table, as we have discussed. The current table is the K&R, 1st edition, and has not been updated in 30 years. Three updates are proposed, The first you have already added to the source. Numbers are the Sections within the C Standard changed. In C89/90 C Standard, the postfix, increment( ++ ) and decrement( -- ) operators, have been promoted to level 1, (Section: 6.3.2) leaving the prefix versions in the unary operators, on Level 2 (Section: 6.3.3). In C89/90 C Standard, the cast operator( (type) ), has been demoted to a new third level, (Section: 6.3.4) inserted between the unary operators, (Section: 6.3.3) and the multiplicative operators, (Section: 6.3.5) expanding the table to 16 levels. In C11 C Standard, a new unary operator, _Alignof has been added to the unary operators (Section: 6.5.3). I have made the additional changes along with the update you have already made. The proposed patch is shown below: diff --git a/man7/operator.7 b/man7/operator.7 index f22dc5d17..2e4b92b9f 100644 --- a/man7/operator.7 +++ b/man7/operator.7 @@ -37,18 +37,22 @@ .\" .\" 2007-12-08, mtk, Converted from mdoc to man macros .\" +.\" 2019-09-30, Updated for 2 changes, and 1 addition +.\" Rick Stanley <rstanley@rsiny.com> .TH OPERATOR 7 2011-09-09 "Linux" "Linux Programmer's Manual" .SH NAME operator \- C operator precedence and order of evaluation .SH DESCRIPTION This manual page lists C operators and their precedence in evaluation. +Updated through the C18 C Standard .PP .TS lb lb lb l l l. Operator Associativity Notes () [] \-> . ++ \-\- left to right [1] -! ~ ++ \-\- + \- (type) * & sizeof right to left [2] +! ~ ++ \-\- + \- * & _Alignof sizeof right to left [2] +(type) right to left * / % left to right + \- left to right << >> left to right -- RSI (Rick Stanley, Inc.) (917) 822-7771 www.rsiny.com Computer Systems Consulting Linux & Open Source Specialists