-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Multidimensional std::array initialization #568
Comments
See #542. |
I do
It's |
This is how you can make it work today (https://cpp2.godbolt.org/z/815eovG3T):
|
I was just trying to cook up a hack to get Cppfront to lower a braced-init-list.
|
this also happens with boost::json
} this is the cpp version of the function I was trying to replace std::string timestamp_str = I get these warnings instead, the code compiles though which I think is dangerous! |
Yeah, that's double balanced parentheses, |
Ah, but requiring |
There's also the option of lowering all expression lists within an initializer as braced-init-lists. |
Describe the bug
Initialization of a two-dimensional std::array appears to be broken.
To Reproduce
Steps to reproduce the behavior:
cppfront compiler v0.2.1 Build 8724:0846
g++ (Debian 12.2.0-14) 12.2.0
Additional context
cppfront
translates theboard
declaration to:i.e., it only replaces the outer parentheses by braces and g++ accepts that silently, although adding
-Wall
does emitwarning: left operand of comma operator has no effect [-Wunused-value]
for each element in the array. Examining the array after initialization ingdb
shows:which explains the actual output.
BTW, is there currently a way to do the equivalent of
constexpr std::size_t ROWS = 3
? I usedROWS: const i32 = 3
but I don't think that equivalent, plus if I'm not mistaken theconst
is superfluous.Also, I tried to write a
for
loop to iterate but couldn't quite get the syntax right.Finally, I tried replacing the
std::array
bystd::vector
andcppfront -p
accepted it as valid, but then g++ did not like the parenthetical initializations.The text was updated successfully, but these errors were encountered: