From -4520894366010944562
X-Google-Thread: f78e5,3c316a202087bfac
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.speakeasy.net!news.speakeasy.net.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 22 Apr 2006 11:20:08 -0500
Return-Path: <devnull@stump.algebra.com>
X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on ak74.algebra.com
X-Spam-Level: ***
X-Spam-Status: No, score=3.4 required=5.0 tests=HEADER_SPAM,MISSING_HEADERS,
	TO_CC_NONE autolearn=disabled version=3.1.1
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Original-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@ucar.edu
From: Ben Hutchings <ben-public-nospam@decadentplace.org.uk>
Subject: Re: Defining undefined, etc., behavior
Message-ID: <20060422123137.GA16196@decadentplace.org.uk>
Reply-To: Ben Hutchings <ben@decadentplace.org.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Newsgroups: comp.std.c++
Organization: private site
User-Agent: Mutt/1.5.9i
X-SA-Exim-Connect-IP: <locally generated>
X-SA-Exim-Mail-From: ben-public-nospam@decadentplace.org.uk
X-SA-Exim-Scanned: No (on shadbolt.decadentplace.org.uk); SAEximRunCond expanded to false
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Date: Sat, 22 Apr 2006 11:17:42 CST
Lines: 32
NNTP-Posting-Host: 65.182.171.162
X-Trace: sv3-OP1y9Wwuj+ixAUqPF5X9hHH55QpjFoMq6W9P4wc8jMY7u9LPVhhKc7OA0Hpp/bs5PVWLbIT3mGK4zHH!+DguwMJ9xwiV7IJcoB3kWY/EEoXWDHJplwftXDfBouIuBuc++hFtTbo+J2qBwLvoA+4ARhzWWSf5!FKe+t+JPuuYS+h+OG9f20h4eR/F1Lg==
X-Complaints-To: abuse@speakeasy.net
X-DMCA-Complaints-To: abuse@speakeasy.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.32
Xref: g2news2.google.com comp.std.c++:1654

James Kanze <kanze.james@neuf.fr> wrote:
<snip>
> Do you write real applications, or just demonstration programs
> for training purposes.  Real applications DO validate input.
<snip>

The steady stream of security advisories for common software shows
that this is not the case even where validation is security-critical,
let alone where it is only protecting the user from himself.

Clearly we need to catch invalid input, but the language should
support that.  At the machine code level, it's faster to test for an
overflow condition after an operation than to work out beforehand
whether overflow is going to happen, and there's less risk of getting
the test wrong; however such condition codes are not exposed to the C
or C++ programmer despite their ubiquity (AFAIK).  (However, if one
check can cover many following operations, that's faster than checking
each of them, so it's hard to generalise about what's preferable.)

Ben.

-- 
Ben Hutchings
The obvious mathematical breakthrough [to break modern encryption] would be
development of an easy way to factor large prime numbers. - Bill Gates

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



