Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #6093
| From | Richard Heathfield <rjh@cpax.org.uk> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: Read again about my objection about C++ and C |
| Date | 2015-12-30 19:41 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <n61bsv$l1r$1@dont-email.me> (permalink) |
| References | <n6188g$6ki$1@dont-email.me> <n618tb$9as$1@dont-email.me> <n619kh$c61$1@dont-email.me> |
On 30/12/15 22:03, Ramine wrote: > Hello, Ah! Welcome to comp.programming! > You are making your argument stupid.. That's an interesting conversational gambit. Let's see how far it gets you. > Because we must have a way in the compiler to discipline the > programmer to not make a mistake, It is not possible, in the general case, for the compiler to prevent the programmer from making mistakes, because the compiler doesn't know what the programmer is supposed to be doing. > you are saying that in C and C++ > you have to test for your logic yourself to not overflow > or underflow, You have to know about the issue, yes, and you have to take sensible precautions when you're up against limits. The pay-off is performance. In almost all cases (but not quite all), the precaution is not required, so why impose that penalty /all/ the time? Why not trust the programmer to put the checks in when they are required? > that's not good, because in FreePascal > and Delphi and Ada, if you want the compiler to discipline > you to not make an error of logic that makes you overflow > or underflow a signed or unsigned int, you can compile your program > in FreePascal with -Co compiler option and after that you can locally > catch the exception of overflow or underflow and reraise an exception > to detect the faulty function that caused it, or you can globally > catch the exception, To summarise your argument: 1) FreePascal and Delphi and Ada allow you to include runtime overflow checks. 2) Therefore, not providing runtime overflow checks is bad. You might want to consider signing up for an Elementary Logic course. Firstly, as I have already explained, doing such checks automatically has a runtime overhead that in almost all cases is not required, so it's mostly just a waste of clocks. Secondly, and you'll laugh when you hear this, by far the most popular C and C++ compiler is gcc, which *does* allow you to set up runtime arithmetic overflow checking if you want to. > but you can not do that in C++ and C , so Well, you can if you want, but normally you don't want because it's normally a complete waste of time. > this is why in my opinion C and C++ are not suitable for > realtime safety critical systems. (a) Your opinion doesn't count for much where the facts are concerned - C and C++ implementations are perfectly free to provide such checking, some implementations /do/ provide such checking, and of course they do so /optionally/; (b) The reason it's optional is that it's very often not a sensible option. There's no point in weighing down code with runtime checks that are never going to fire. What /is/ sometimes a good idea is to enable such checks during testing, and design some test cases to expose any overflow issues. <snip> One other thing - please learn why top-posting is such a stupid, stupid, stupid idea. Thank you. -- Richard Heathfield Email: rjh at cpax dot org dot uk "Usenet is a strange place" - dmr 29 July 1999 Sig line 4 vacant - apply within
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Read again about my objection about C++ and C Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 18:50 +0000
Re: Read again about my objection about C++ and C Öö Tiib <ootiib@hot.ee> - 2015-12-30 11:28 -0800
Re: Read again about my objection about C++ and C Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 19:48 +0000
Re: Read again about my objection about C++ and C Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 19:51 +0000
Re: Read again about my objection about C++ and C Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 20:07 +0000
Re: Read again about my objection about C++ and C fir <profesor.fir@gmail.com> - 2015-12-30 11:34 -0800
Re: Read again about my objection about C++ and C Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 19:41 +0000
Re: Read again about my objection about C++ and C Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 19:51 +0000
Re: Read again about my objection about C++ and C Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 20:06 +0000
Re: Read again about my objection about C++ and C Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 20:06 +0000
csiph-web