linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] operator.7: Fix precedence of the 'cast operator'
@ 2021-08-28 12:11 Alejandro Colomar
  2021-08-28 12:11 ` [PATCH 2/2] operator.7: Reorder symbols as in the standard (C11) Alejandro Colomar
  0 siblings, 1 reply; 2+ messages in thread
From: Alejandro Colomar @ 2021-08-28 12:11 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, David Sletten, Jakub Wilk

Unary operators are mentioned in C11::6.5.3, and casts are in
C11::6.5.4 (they are mentioned in order of precedence).

And from note 85 (in section 6.5) in that same C11 standard, major
subsections 6.5.X are sorted by precedence.

As an example (from Jakub), `sizeof(int)+1` is interpreted as
`(sizeof(int))+1`, and not `sizeof((int)+1)`.

I used C11 and not C18 (the latest) because at least in the draft
copy of C18 that I have, there are a few important typos in that
section, while the draft copy of C11 that I have is free of those
typos.  And C11 and C18 are almost identical, with no major
changes to the language.

Reported-by: David Sletten <david.paul.sletten@gmail.com>
Cc: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
 man7/operator.7 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/man7/operator.7 b/man7/operator.7
index b0bac5f4e..22c107c7f 100644
--- a/man7/operator.7
+++ b/man7/operator.7
@@ -48,7 +48,8 @@ lb lb lb
 l l l.
 Operator	Associativity	Notes
 () [] \-> . ++ \-\-	left to right	[1]
-! \(ti ++ \-\- + \- (type) * & sizeof	right to left	[2]
+! \(ti ++ \-\- + \- * & sizeof	right to left	[2]
+(type)	right to left
 * / %	left to right
 + \-	left to right
 << >>	left to right
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] operator.7: Reorder symbols as in the standard (C11)
  2021-08-28 12:11 [PATCH 1/2] operator.7: Fix precedence of the 'cast operator' Alejandro Colomar
@ 2021-08-28 12:11 ` Alejandro Colomar
  0 siblings, 0 replies; 2+ messages in thread
From: Alejandro Colomar @ 2021-08-28 12:11 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man

This makes it easier to compare this page to the standard,
to get more details about the rules between operators.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
 man7/operator.7 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/man7/operator.7 b/man7/operator.7
index 22c107c7f..2770c5806 100644
--- a/man7/operator.7
+++ b/man7/operator.7
@@ -47,13 +47,13 @@ This manual page lists C operators and their precedence in evaluation.
 lb lb lb
 l l l.
 Operator	Associativity	Notes
-() [] \-> . ++ \-\-	left to right	[1]
-! \(ti ++ \-\- + \- * & sizeof	right to left	[2]
+[] () . \-> ++ \-\-	left to right	[1]
+++ \-\- & * + \- \(ti ! sizeof	right to left	[2]
 (type)	right to left
 * / %	left to right
 + \-	left to right
 << >>	left to right
-< <= > >=	left to right
+< > <= >=	left to right
 == !=	left to right
 &	left to right
 \(ha	left to right
@@ -61,7 +61,7 @@ Operator	Associativity	Notes
 &&	left to right
 ||	left to right
 ?:	right to left
-= += \-= *= /= %= <<= >>= &= \(ha= |=	right to left
+= *= /= %= += \-= <<= >>= &= \(ha= |=	right to left
 ,	left to right
 .TE
 .PP
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-28 12:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-28 12:11 [PATCH 1/2] operator.7: Fix precedence of the 'cast operator' Alejandro Colomar
2021-08-28 12:11 ` [PATCH 2/2] operator.7: Reorder symbols as in the standard (C11) Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).