Re: [Rd] simple C function segfaults

From: Prof Brian D Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 21 Feb 2006 - 21:11:46 GMT

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@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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed Feb 22 08:19:48 2006

This archive was generated by hypermail 2.1.8 : Wed 22 Feb 2006 - 19:30:50 GMT