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/index.cgi?page=PlusPlusOperator
My post in Comp.Lang.C:
http://groups.google.se/group/comp.lang.c/browse_thread/thread/716804e05dc001a9/5851243b04c893e5
Thanks,
Per
--
Per Erik Strandberg
blog: http://www.pererikstrandberg.se/blog/
work: http://tomopt.com/tomnet/
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