Thank you for the very measured response.

It seems that under C the register keyword mostly helps to avoid getting the address of those variables (it is forbidden) and helps optimization in that way.

Under C++ most compilers (according to reports) ignore the register keyword altogether.

 

Overall, modern C++ compilers and optimizers have less and less a 1:1 relationship between C++ instructions and assembly code. For fine control it is the wrong lagnuage I would say.

 

Look at Nvidia (not sure if it is the ideal example?!): They have nvcc for compiling C++ code into an abstract machine with infinite registers (PTX code) and then ptxas, which compiles into the actuall assembler code (SASS). A lot of optimizations are done in the ptxas step.

 

The LLVM compiler has as direction for many hardware systems the MLIR infrastructure, where compilation is done in multiple independent steps and layers.

 

Yes, there is ABI defined for C/C++ on the machine (and register) level. But it is meant as an interface, not as a performance optimizing fine control.


 

-----Ursprüngliche Nachricht-----
Von: David Brown <david.brown@hesbynett.no>
Gesendet: Di 22.09.2026 09:40
Betreff: Re: [std-proposals] PROPOSAL: Reintroduce register — wise for developer-first decisions.
An: std-proposals@lists.isocpp.org;
CC: Sebastian Wittmeier <wittmeier@projectalpha.org>;
C++ already defines "asm" as a keyword, with almost no specified syntax
or semantics except to say it is an implementation-defined way to pass
information to an assembler.  That's a good compromise, IMHO - there is
no attempt to define what "inline assembly" means or how it works, but
implementations at least know they can use the keyword "asm" for the
purpose.

Many compilers - gcc, clang, and others - support "register variables"
with a syntax like :

register int foo asm("r10");

I don't think the "register" part is really necessary - it should be
realistic (and I say this without knowing anything about the internals
of gcc!) to use the same syntax without the "register" keyword if it is
ever repurposed in C++ for something incompatible.

So as things stand, there is already a way to get implementation-defined
specific register allocation that the OP wanted.  At most, all the C++
standard needs is a note that "asm declaration" can be used as part of
other declarations.  (At the same time, it should be changed to allow
anything inside the parentheses, not just a string-literal.)

As you say, it makes no sense to try to say what "asm" actually does in
the C++ standards - it cannot be described in terms of the abstract
machine.  But it is feasible to be a little bit clearer on the preferred
syntax for implementation-specific "asm" extensions so that there is
minimal chance of conflicts later.  And it could avoid "register"
entirely, rather than "re-introducing" it in some way.

David