Re: compiler smarts: register variables and catching exceptions
andrew_nuss@yahoo.com wrote:
I have a long running loop that uses 4 stacks whose pointers
are declared as register variables and which catches a
SpecialException. The question is whether the introduction of
the catch block will destroy register optimizations, and force
the compiler to ignore using registers to hold the stack
pointers.
Almost all modern compilers ignore the register specifier
anyway, because they can do a better job of it than you can.
Anyway, any answer would be implementation dependent. Is the
program fast enough, or not? And if not, does the profiler
indicate that this is where the problem is? If the answer to
both is yes, you *might* look at the generated code, to see what
is really happening. But generally, I wouldn't worry about it.
With or without the register specifier, if the variables are
really intensively used, the compiler will put them in registers
during the loop. Possibly spilling them back to memory before
any throw, or any function which might throw.
--
James Kanze GABI Software
Conseils en informatique orient��e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S��mard, 78210 St.-Cyr-l'��cole,
France, +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]