TITLE: Compilers and register variables PROBLEM: ded@aplcen.apl.jhu.edu (nod sivad) In the past, to speed up a C function's performance, one would declare frequently used variables as "register." But what happens with a C++ inline function? Does declaring the variables as "register" offer any hope of greater speed? P.S. Supposedly, compilers are so sophisticated nowadays that the "register" keyword is unnecessary. Would any compiler writers care to comment on this? PROBLEM: steve@taumet.com (Steve Clamage), 9 Dec 92 Declaring a variable as "register" has no defined semantics, except that you can't then take its address. Using register variables in an inline function doesn't change that. You have to read your compiler documentation to see what it says about register variables, the effect of register declarations, and when to use (and not to use) the declarations. Compilers differ. Most modern compilers ignore register declarations when deciding how to allocate variables. A good compiler will make better decisions about allocation than the programmer can. If you force a variable into a register, you may force less efficient code generation for other aspects of the function. A good compiler evaluates all the costs and benefits and assigns variables accordingly. It might put a variable into a register for part of a function, and use the register for something else in another part. RESPONSE: p j l @cs.uiuc.edu (Paul Lucas) AT&T Bell Laboratories *****> Actually, in C++ you can take the address of a register variable. (This will _force_ the variable to not be put into a register, however.)