logoalt Hacker News

RobotToastertoday at 7:51 AM1 replyview on HN

It's still weird to me that you can declare an array with the register keyword.

Then it (understandably) becomes UB to attempt to get the pointer.

(It also probably isn't stored in a register, since the keyword is just asking the compiler nicely.)


Replies

flohofwoetoday at 7:58 AM

The meaning of the 'register' keyword has changed over time to just "it's illegal to take the address of this item":

https://www.godbolt.org/z/TKq9rWzP1

Don't know what's the idea behind not allowing to take the address of a value though.

show 3 replies