comp.lang.ada
 help / color / mirror / Atom feed
From: John McCabe <john@nospam.assen.demon.co.uk>
Subject: Re: C++0x and Threads - a poor relation to Ada's tasking model?
Date: Fri, 14 Aug 2009 15:30:26 +0100
Date: 2009-08-14T15:30:26+01:00	[thread overview]
Message-ID: <2kra85p2lsrd7200mcfr9fn65s123468br@4ax.com> (raw)
In-Reply-To: 57766742-5e6e-4b68-8094-57db1fa8951d@s15g2000yqs.googlegroups.com

On Fri, 14 Aug 2009 06:00:05 -0700 (PDT), REH <spamjunk@stny.rr.com>
wrote:

>On Aug 14, 7:09�am, John McCabe <j...@nospam.assen.demon.co.uk> wrote:
>> Under the circumstances I use C/C++ to represent C and C++ as this
>> particular example is common to both; they both incorpoate
>> overwrapping semantics for operations on integer types (unlike Ada,
>> which provides a separate Modular type for that purpose).
>
>C++ and C provide separate types of that purpose also. Signed and
>unsigned integers are not the same type. They have different rules.
>It's a common misconception that signed integers portably wrap. Signed
>integer do not have "overwrapping sematics."

I bow to your superior knowledge of the C++ standard. I assume you're
referring to something like this C++ section:

"If during the evaluation of an expression, the result is not
mathematically defined or not in the range of representable values for
its type, the behavior is undefined, unless such an expression is a
constant expression (5.19), in which case the program is ill-formed.
[Note: most existing implementations of C++ ignore integer overflows.
Treatment of division by zero, forming a remainder using a zero
divisor, and all floating point exceptions vary among machines, and is
usually adjustable by a library function. ]"

Thank you for that clarification.

Very intriguing note though, a standard that tells you how most
implementations deal with it!

... and this C Section (so to speak!):

"C�s unsigned integer types are ��modulo�� in the LIA-1 sense in that
overflows or out-of-bounds results silently wrap. An implementation
that defines signed integer types as also being modulo need not detect
integer overflow, in which case, only integer divide-by-zero need be
detected."

That's from some section on language independent arithmentic, I
couldn't find anything else.

>Using C/C++ is frowned upon by both the C and C++ communities.

Never mind.

>Even in
>your simple example, the languages have different rules as to what is
>portable.

Not significantly as far as I can see; C++ says behaviour on overflow
on signed integers is undefined, and C seems to say that it's up to
the implementation (which seems like the same thing). Both say
unsigned overflow doesn't occur because they use modulo arithmetic.

Unless of course I'm looking in the wrong place.

>> >Ada has specific requirements for
>> >what happens when your Int16 overflows. C++ considered a signed
>> >integer overflow undefined behavior. The compiler is allowed to do
>> >anything it wants.
>>
>> Oh dear.
>
>That! That is the only point I was trying to make in answering your
>original question of how the communities are different. You are
>appalled by that because it is not safe. The C++ community is not
>because it allows the compiler maximum flexibility for raw speed.
>Which position is "better" wasn't my point, only the fact that the
>difference exists.

Ok. Thanks for that. I think we'll have to agree to disagree on this.
I personally don't see that there is a significant difference in need
between users of Ada and C++ in general. Obviously you do. The
question of raw speed over safety is a moot point in my view as a huge
amount of the safety of Ada comes from the fact that problems can be
detected at compile time; the generation of code is a different matter
and that all depends on the cleverness of those writing the compilers.
As an example, when I used the TLD Ada 83 compiler for MIL-STD-1750A
it came out with some phenomenally tight code using instructions that
might not have been the first one that would have sprung to mind had
you been writing the code in assembler. Conversely, when using C on a
DSP56001 with the g56k compiler, it generated code where every
variable to variable assignment was surrounded by the set up of a loop
with 1 iteration.

Anyway. Thanks again.



  reply	other threads:[~2009-08-14 14:30 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-11 15:30 C++0x and Threads - a poor relation to Ada's tasking model? John McCabe
2009-08-11 20:51 ` Maciej Sobczak
2009-08-12 12:25   ` John McCabe
2009-08-12 14:51     ` Maciej Sobczak
2009-08-12 15:56     ` REH
2009-08-12 16:59       ` John McCabe
2009-08-12 17:21         ` REH
2009-08-12 20:41           ` Robert A Duff
2009-08-12 21:15             ` REH
2009-08-13  1:28               ` Randy Brukardt
2009-08-13  2:08                 ` REH
2009-08-13  8:38                   ` Pascal Obry
2009-08-13  8:57                     ` Dmitry A. Kazakov
2009-08-13 11:32                       ` Pascal Obry
2009-08-13 12:28                         ` Dmitry A. Kazakov
2009-08-14  1:15                           ` Brian Drummond
2009-08-14 11:24                           ` Language checks (Was: C++0x and Threads - a poor relation to Ada's tasking model?) Jacob Sparre Andersen
2009-08-14 12:01                             ` Dmitry A. Kazakov
2009-08-14 13:33                               ` REH
2009-08-14 13:48                                 ` John McCabe
2009-08-14 14:51                                   ` John McCabe
2009-08-14 14:13                                 ` Dmitry A. Kazakov
2009-08-14 19:58                                   ` Language checks Robert A Duff
2009-08-15  0:10                             ` Language checks (Was: C++0x and Threads - a poor relation to Ada's tasking model?) Randy Brukardt
2009-08-14 13:10               ` C++0x and Threads - a poor relation to Ada's tasking model? Gautier write-only
2009-08-14 13:16                 ` REH
2009-08-12 21:24             ` REH
2009-08-13 13:51               ` John McCabe
2009-08-13 16:24                 ` REH
2009-08-14 11:09                   ` John McCabe
2009-08-14 13:00                     ` REH
2009-08-14 14:30                       ` John McCabe [this message]
2009-08-14 14:49                         ` REH
2009-08-14 14:54                           ` John McCabe
2009-08-14 15:35                             ` REH
2009-08-14 18:43                               ` Robert A Duff
2009-08-14 18:54                                 ` REH
2009-08-14 22:33                                   ` Robert A Duff
2009-08-15  1:15                                     ` REH
2009-08-15 14:24                                       ` Robert A Duff
2009-08-14 15:09                           ` Hyman Rosen
2009-08-14 15:12                             ` REH
2009-08-13 13:55           ` John McCabe
2009-08-13 16:45             ` REH
2009-08-14 11:14               ` John McCabe
2009-08-12 20:53         ` Maciej Sobczak
2009-08-11 23:53 ` jimmaureenrogers
2009-08-12  0:06   ` Jeffrey R. Carter
2009-08-12  7:26   ` Maciej Sobczak
2009-08-12  5:29     ` stefan-lucks
2009-08-12 15:00       ` Maciej Sobczak
2009-08-12  9:27     ` Ludovic Brenta
2009-08-12 15:14       ` Maciej Sobczak
2009-08-13 12:47         ` Peter C. Chapin
2009-08-13 13:57           ` John McCabe
2009-08-14  7:39           ` Maciej Sobczak
2009-08-14 11:13             ` John McCabe
2009-08-14 12:23               ` Dmitry A. Kazakov
2009-08-14 12:50                 ` John McCabe
2009-08-14 13:50                   ` Dmitry A. Kazakov
2009-08-14 13:58                     ` Niklas Holsti
2009-08-14 14:17                       ` Dmitry A. Kazakov
2009-08-14 22:25                       ` Brian Drummond
2009-08-14 12:56             ` John McCabe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox