Compiler behavior and registry storage class specifier are deprecated "

I am testing C ++ code with -std=c++11

. I noticed a warning that I hadn't seen before:

'register' storage class specifier is deprecated

What does the standard say about this (besides its outdated one)?

Is the implementation defined?

Will compilers compile as a hint and try to put the value in a register?

Will it eventually crash compilation?

Perhaps something else?

+3


source to share


2 answers


C ++ 11, [dcl.stc] :

3 - The specifier register

is an implementation hint that the declared variable will be heavily used. [Note: the hint can be ignored, and in most implementations it will be ignored if the address of the variable is taken. This usage is deprecated (see D.2). - end note]



There is a suggestion to remove the keyword register

as a storage specifier by reserving it as a keyword: Remove obsolete keyword usage register

(n4340)
. This may or may not be implemented in C ++ 1z (pre-C ++ 17); this would create problems for compatibility with C, where register

it still has a semantic effect (a C variable or parameter register

cannot have its address or decay from matrix to pointer).

+10


source


Is the implementation defined?

It has always been.

Will compilers compile as a hint and try to put the value in a register?

Defined for implementation.



Will it eventually crash compilation?

Not.

EDIT I may have misunderstood the question about possible compilation failure. I took this as a possible failure in the current compilation. If the question is about the future of a keyword register

, anything is possible: I care to predict.

+6


source







All Articles