Question on generated cpp for constexpr object #731
-
Hi. I finally got a chance today to try out the constexpr functionality that was added recently. Functions worked exactly as I expected, but I was surprised by the generated cpp for constexpr objects. This is the example from the last update
compiles to this cpp code
but I was expecting something more like this cpp code
The actual code cannot be used where constexpr is required. For example:
Is this the intended design? Because it doesn't seem to be usable when constexpr is required. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
This is the intended design, although perhaps outdated. |
Beta Was this translation helpful? Give feedback.
-
Thanks! This is just an oversight. Will fix. Note that when the above is a non-local variable, it does lower to a When I made the change, I meant (but forgot) to check that the same (except not Note that if you do want the equivalent of a local
|
Beta Was this translation helpful? Give feedback.
This is the intended design, although perhaps outdated.
At b589f5d#commitcomment-129028450, I argue that this should also lower to a
constexpr
object.