Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #6090
| Newsgroups | comp.programming |
|---|---|
| Date | 2015-12-30 11:28 -0800 |
| References | <n6188g$6ki$1@dont-email.me> <n618tb$9as$1@dont-email.me> <n619kh$c61$1@dont-email.me> |
| Message-ID | <3bed0922-bb93-464d-9f44-aa66f28c134d@googlegroups.com> (permalink) |
| Subject | Re: Read again about my objection about C++ and C |
| From | Öö Tiib <ootiib@hot.ee> |
Your own argument is stupid.
It is irrelevant for a user of real-time critical incorrect program
what way it burns down: by giving incorrect answers or by throwing
out run-time errors.
Developer can compile with gcc -ftrapv option if he wants integer
overflow to be detected run-time in C or C++. Developers use it
for testing. However giving defective safety-critical software to user
with such run-time checks is still as bad. It just runs slightly slower
but is still as incorrect.
On Wednesday, 30 December 2015 21:03:14 UTC+2, Ramine wrote:
> Hello,
>
>
> You are making your argument stupid..
>
> Because we must have a way in the compiler to discipline the
> programmer to not make a mistake, you are saying that in C and C++
> you have to test for your logic yourself to not overflow
> or underflow, 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, but you can not do that in C++ and C , so
> this is why in my opinion C and C++ are not suitable for
> realtime safety critical systems.
>
>
>
> Thank you,
> Amine Moulay Ramdane.
>
>
>
> On 12/30/2015 10:50 AM, Richard Heathfield wrote:
> > On 30/12/15 21:39, Ramine wrote:
> >
> > [Subject line: Read again about my objection about C++ and C]
> >
> > Since your knowledge of good C++ programming style is so limited that
> > you still use 'using namespace std', can you persuade us that your views
> > on C and C++ are worth anything?
> >
> > <snip>
> >
> >> So what remains about C and C++ is that in C++ and C you can
> >> not at runtime catch the exception of signed int or unsigned int
> >> overflow or underflow ,
> >
> > In C and C++, it is not possible to overflow or underflow unsigned
> > integer types, so there is no way for the exception to be generated.
> > Even with signed integer types, there is no requirement on architectures
> > to generate an exception for overflow, and C does not mandate that
> > implementations carry out software checks, for the excellent reason that
> > programmers who design their software in such a way that overflow cannot
> > happen should not be penalised by extra checks every time they add two
> > numbers together:
> >
> > int quadratic(int x, int a, int b, int c)
> > {
> > return a * x * x + b * x + c;
> > }
> >
> > int foo()
> > {
> > y = quadratic(3, 2, -3, 4);
> > z = quadratic(2, 3, -1, 6);
> > return y + z;
> > }
> >
> > For such code, it would be folly to impose a run-time penalty.
> >
> >> this is a weakness in C++ and C ,
> >
> > No, it isn't.
> >
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