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?
source to share
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).
source to share
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.
source to share