[Rd] simple C function segfaults
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Tue Feb 21 22:11:46 CET 2006
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
More information about the R-devel
mailing list