Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #6088

Re: Read again about my objection about C++ and C

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 18:50 +0000
Organization A noiseless patient Spider
Message-ID <n618tb$9as$1@dont-email.me> (permalink)
References <n6188g$6ki$1@dont-email.me>

Show all headers | View raw


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.

-- 
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 — Next in thread | Find similar | Unroll thread


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