From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,4215feeab2a8154a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!goblin3!goblin2!goblin.stu.neva.ru!aioe.org!not-for-mail From: John McCabe Newsgroups: comp.lang.ada Subject: Re: C++0x and Threads - a poor relation to Ada's tasking model? Date: Fri, 14 Aug 2009 15:30:26 +0100 Organization: Aioe.org NNTP Server Message-ID: <2kra85p2lsrd7200mcfr9fn65s123468br@4ax.com> References: <128d63da-361f-4e33-be5e-e06bdc71e39f@r34g2000vba.googlegroups.com> <850893f5-46e5-443f-af0f-f16eef5cfa37@n2g2000vba.googlegroups.com> <57766742-5e6e-4b68-8094-57db1fa8951d@s15g2000yqs.googlegroups.com> NNTP-Posting-Host: RXEkuaSUwmKe0XIGFYSK7A.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.7.9 X-Newsreader: Forte Agent 2.0/32.652 Cancel-Lock: sha1:/8TWsojjbaU9sIfHz5Jm4vG49MM= Xref: g2news2.google.com comp.lang.ada:7788 Date: 2009-08-14T15:30:26+01:00 List-Id: On Fri, 14 Aug 2009 06:00:05 -0700 (PDT), REH wrote: >On Aug 14, 7:09�am, John McCabe 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.