From ripley at stats.ox.ac.uk  Tue Feb 21 22:11:46 2006
From: ripley at stats.ox.ac.uk (Prof Brian D Ripley)
Date: Tue, 21 Feb 2006 21:11:46 +0000 (GMT Standard Time)
Subject: [Rd] simple C function segfaults
In-Reply-To: <1AF14F32-B953-4D58-A02B-A5ED0F3FA8CA@r-project.org>
References: <20060221194810.46878.qmail@web27414.mail.ukl.yahoo.com>
	<1AF14F32-B953-4D58-A02B-A5ED0F3FA8CA@r-project.org>
Message-ID: <Pine.WNT.4.64.0602212106490.4076@auk>

On Tue, 21 Feb 2006, Simon Urbanek wrote:

>
> On Feb 21, 2006, at 2:48 PM, Bernd Kriegstein wrote:
>
>> Thank you very much for the answer. As a general principle, when
>> and why should I register the counters?
>
> "register int i" is merely an optimization, you can safely use "int
> i" instead. The "register" keyword only tells the compiler to store
> the variable in a CPU register where possible - it is not necessary
> at all (most modern compiler will optimize it correctly anyway).

I actually think you should leave this off with an optimizing compiler. 
They are better at optimizing register use than humans!  I believe there 
are only a few dozen `register' statements in the R code base, almost all 
of which are in code borrowed or generated (e.g. gram.c).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] simple C function segfaults
Prof Brian D Ripley