473,499 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The inconsistent between BSD and c-faq on precedence

c-faq, 4.3:
The postfix ++ and -- operators essentially have higher precedence
than the prefix unary operators.

BSD Manual, OPERATOR(7):
Operator Associativity
-------- -------------
! ~ ++ -- - (type) * & sizeof right to left

Is there a complete table on operators, their precedence and
associativity in the standard document?

Oct 7 '06 #1
7 1772
lovecreatesbea...@gmail.com said:

<snip>
Is there a complete table on operators, their precedence and
associativity in the standard document?
As has already been explained here very recently, the grammar determines how
statements are parsed. The Standard does contain the grammar, of course.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 7 '06 #2

Richard Heathfield wrote:
lovecreatesbea...@gmail.com said:
Is there a complete table on operators, their precedence and
associativity in the standard document?

As has already been explained here very recently, the grammar determines how
statements are parsed. The Standard does contain the grammar, of course.
Thank you. Could you please direct me to the grammar on precedence in
the standard? For it is a little difficult on natural language
(English, Chinese ...) reading for me to read through the whole
document to look up one thing in it.

I have found the similar inconsistent between K&R2 and H&S5 on the
precedence.

Oct 7 '06 #3
lovecreatesbea...@gmail.com said:
>
Richard Heathfield wrote:
>lovecreatesbea...@gmail.com said:
Is there a complete table on operators, their precedence and
associativity in the standard document?

As has already been explained here very recently, the grammar determines
how statements are parsed. The Standard does contain the grammar, of
course.

Thank you. Could you please direct me to the grammar on precedence in
the standard?
There isn't any "grammar on precedence". There's just grammar. The grammar
defines how things are parsed. See Section 6.5 Expressions.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 7 '06 #4
lovecreatesbea...@gmail.com wrote:
c-faq, 4.3:
The postfix ++ and -- operators essentially have higher precedence
than the prefix unary operators.

BSD Manual, OPERATOR(7):
Operator Associativity
-------- -------------
! ~ ++ -- - (type) * & sizeof right to left

Is there a complete table on operators, their precedence and
associativity in the standard document?

According to Harbison and Steele, we have
postfix ++ and postif -- with precedence 16

Unary operators ~ , ! , have precedence 15,
i.e. lower precedence, so the C Faq is right.

You have propbably confused postfix ++ with
*prefix* ++, that has the same precedence as the
unary operators. Maybe, since this is not specified
in the BSD table you showed, there is just
a msunderstanding.
Oct 7 '06 #5
On 7 Oct 2006 06:38:50 -0700, "lovecreatesbea...@gmail.com"
<lo***************@gmail.comwrote:
>c-faq, 4.3:
The postfix ++ and -- operators essentially have higher precedence
than the prefix unary operators.
Notice the word essentially. In this context, it means what follows
is not precisely correct but has the same effect as if it were.
>
BSD Manual, OPERATOR(7):
Operator Associativity
-------- -------------
! ~ ++ -- - (type) * & sizeof right to left
Consider the following code snippet inside a function:
int i[2] = {3,4};
int *p = i;
int j = --*p++;

Since --, *, and ++ have the same "official" precedence,
associativity acts as a tie breaker. Thus, the right had side is
evaluated as --(*(p++)). This is the same result you would get IF
postfix had higher precedence than prefix.
p++ evaluates to the current value of p and sometime before this
statement is complete will increment p.
*p++ evaluates to 3, the value of the int p initially pointed to.
--*p++ evaluates to one less than this value and sometime before
the statement is complete will decrement the value in its original
location.

When all is said and done, j is assigned the value 2, i[0] is
decremented to 2, and p points to i[1] which is unchanged..
>
Is there a complete table on operators, their precedence and
associativity in the standard document?
If you have access to K&R, Table 2-1 on page 53 may be what you are
looking for.
Remove del for email
Oct 7 '06 #6
lovecreatesbea...@gmail.com wrote:
c-faq, 4.3:
The postfix ++ and -- operators essentially have higher precedence
than the prefix unary operators.

BSD Manual, OPERATOR(7):
Operator Associativity
-------- -------------
! ~ ++ -- - (type) * & sizeof right to left

Is there a complete table on operators, their precedence and
associativity in the standard document?
...
The reason for this is that in C language where both prefix --/++ and
postfix --/++ cannot be meaningfully applied to the same operand. The
resulting code would produce undefined behavior anyway. For this reason,
just to make the table a bit more compact, BSD manual does not separate
--/++ into their prefix and postfix forms.

The C FAQ approaches the same issue from more pedantic/theoretical point
of view. According to C grammar, postfix --/++ operators have higher
precedence than prefix --/++ operators.

In C++ language, for example, this issue has practical value, since in
general case overloaded --/++ operators can be meaningfully applied to
the same operand. That's why in C++-specific precedence table you'll
normally see prefix and postfix --/++ described separately. But in C
there's no practical reason to do that.

--
Best regards,
Andrey Tarasevich

Oct 8 '06 #7

"lovecreatesbea...@gmail.com" <lo***************@gmail.comwrote in message
news:11********************@e3g2000cwe.googlegroup s.com...
c-faq, 4.3:
The postfix ++ and -- operators essentially have higher precedence
than the prefix unary operators.

BSD Manual, OPERATOR(7):
Operator Associativity
-------- -------------
! ~ ++ -- - (type) * & sizeof right to left

Is there a complete table on operators, their precedence and
associativity in the standard document?
Sorry, no.

"lovecreatesbea...@gmail.com" <lo***************@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
I have found the similar inconsistent between K&R2 and H&S5 on the
precedence.
The first precedence table here is for K&R C:
http://groups.google.com/group/comp....a1783275?hl=en

The second is for ANSI C 1989 (or ISO C 1990):
http://groups.google.com/group/comp....72cc3eec?hl=en

Do the differences seem to correspond to the differences in K&R2 and H&S5?
They do to me.

Rod Pemberton
Oct 8 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2703
by: Fine | last post by:
Hallo, ich habe ein midlet mit eclipse erstellt und erhalte folgende Fehlermeldung Error verifying method Approximate bytecode offset 5 Inconsistent or missing stackmap at target Probleme...
10
2008
by: Jerzy Karczmarczuk | last post by:
Gurus, before I am tempted to signal this as a bug, perhaps you might convince me that it should be so. If I type l=range(4) l.extend() l gives , what else... On the other hand, try
0
1417
by: jlea | last post by:
I'm getting the following link error in my C++/.NET C++ project: error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (tagTOOLINFOA):...
1
6071
by: Peter Steele | last post by:
I've created an unmanaged C++ DLL and when I compile it I get numerous errors of the form xyz.cpp(nnn): warning C4273: '<somefunction>' : inconsistent dll linkage I have other DLLs that have...
3
1865
by: codeman | last post by:
Hi all Lets say we have two tables: Customer: Customer_number : Decimal(15) Name : Char(30) Purchase: Purchase_number : Decimal(15)
1
13909
by: James | last post by:
When I ran db2dart to check a database, I got the following warning and error messages. 1.Warning: The database state is not consistent. 2.Warning: Errors reported about reorg rows may be due to...
1
3209
by: bachyen | last post by:
I have the following code, but it is error when I build it. Can you help me? Can you tell me more about 'Inconsistent accessibility: return type', 'Inconsistent accessibility: parameter type'. ...
3
6166
by: Rahul Babbar | last post by:
Hi All, When could be the possible reasons that could make a database inconsistent? I was told by somebody that it could become inconsistent if you " force all the applications to a close on...
0
1114
by: johnthawk | last post by:
In the below code setting cell to inconsistent sets entire column inconsistent (renderer).However, I need a third state off | on | inconsistent . How can I change one path->cell? Any help...
9
1497
by: Lie | last post by:
I've noticed some oddly inconsistent behavior with int and float: Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) on linux2 -345 works, but Traceback (most recent call last): File...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.