473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

increment

Hi, yesterday I experimented with the increment/++ operator. It seems
some behavior is not defined in C (as I was informed when posting on
Comp.Lang.C) - does the same go for C#? Is it clear what f.x: "b2[c2+
+] = a[c2];" does in C#? Is it possible that a compiler, when going
from C# to CIL, could make "different" interpretations of my code.

I compiled with cs for .NET 1.x and 2.x and also mcs with identical
result. But gcc and cl produced different result from similar c-code
(the origin of my question).

Experimental details: http://www.pererikstrandberg.se/blog...usPlusOperator

My post in Comp.Lang.C:
http://groups.google.se/group/comp.l...51243b04c893e5

Thanks,
Per

--

Per Erik Strandberg
blog: http://www.pererikstrandberg.se/blog/
work: http://tomopt.com/tomnet/

Apr 3 '07 #1
1 1605
On Apr 3, 7:35 am, "per9000" <per9...@gmail.comwrote:
Hi, yesterday I experimented with the increment/++ operator. It seems
some behavior is not defined in C (as I was informed when posting on
Comp.Lang.C) - does the same go for C#? Is it clear what f.x: "b2[c2+
+] = a[c2];" does in C#?
Absolutely.
Is it possible that a compiler, when going
from C# to CIL, could make "different" interpretations of my code.
Only if it's broken.

The C# 1 spec (simpler than 2 or 3!) is available in handy HTML form
here:
http://www.jaggersoft.com/csharp_standard/index.htm
The order of evaluation is specified. There are *some* things the C#
standard doesn't specify (where it makes sense not to) but things like
the above are well-specified.

However, I'd still argue that it's very, *very* rarely a good idea to
write code which requires you to be a language lawyer to read it. It's
nice to know that the C# spec guarantees the order of execution, but
readers are likely to find it easier if you just make it obvious what
will happen.

Jon

Apr 3 '07 #2

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

Similar topics

9
by: Mark Turney | last post by:
I was reading "Practical C++ Programming" yesterday, and it mentioned that the order of execution for post-increment and post-decrement operators was ambiguous. I had previously learned that a...
8
by: lovecreatesbeauty | last post by:
Hello experts, Why can this difference between prefix increment/decrement and postfix increment/decrement reside in built-in operators for built-in data types? Thanks. // test.cpp // //...
2
by: Tom | last post by:
I am trying to store information into a table that has an auto increment field. There is currently no data in the table. Using the code below I cannot insert data into the table. I get an error...
13
by: kailasam | last post by:
Hello, Iam having a doubt. Which is more efficient post increment or Pre increment? I have read that preincrement is efficient than Post increment. Iam not able to think how it is? For an...
1
by: Krish | last post by:
Is it true that I cannot increment in decimals, I would like to increment the control by .25 thanks
3
by: George Ter-Saakov | last post by:
What is the purpose of having Interlocked.Increment if it does not work with variable declared as volatile. Here is my problem, Interlocked.Increment increments the variable in thread safe...
2
by: john | last post by:
Is it true that if I split my access database in backend and frontend and I implement custom auto increment for the ID fields, that my database is ready to be used in a multi-user environment? I...
15
by: Ryan Liu | last post by:
Hi, Is there any known bug related to Interlocked.Increment(ref var)? My client report var's value going up and down in the client/server multile-thread application. There are about 80...
11
by: divya_rathore_ | last post by:
The code: int aaa = 100; printf("%d %d %d\n", --aaa, aaa, aaa--); printf("%d\n", aaa); prints: 99 100 100 98
8
by: bintom | last post by:
Why doe the following C++ code behaves as it does? int i; i=1; cout << (++i)++; Output: 2 i=1; cout << ++(++i); Output: 3 i=1; cout << (i++)++; Output: Error. LValue required...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.