-
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] Inconsistent Initialization #823
Comments
This sounds like a regression.
|
@JohelEGP Did you put this comment on the wrong issue? |
No. |
I don't see how any of those things involving lists relate to initializing an int with a double. Which solution would change that behavior? |
I suppose it isn't too much of a problem, actually.
This one in particular would change today's |
Okay, I was looking at just the code as written, not thinking about adding syntax to call a constructor. I would expect passing Ah, the narrowing error is currently coming from the cpp1 side. |
I like option 2, don't want fallback semantics and I don't think there would be any problem if cpp2 would just use |
Can arguments be checked for narrowing from Cpp2 side before generating Cpp1 code? |
Not generally. |
I think I found a bug with initialization
Now, I don't know if this is intentional or not but I think this should not work. |
Description
The result of initialization is surprising because by changing the placement of
=
, its result can be changed, and no one expects to have a different result from the same(args...)
in similar variable declarations.To Reproduce
For example:
I'm using Cppfront from Compiler Explorer.
I expect the value of both
var1
andvar2
to be the same. But theirvalue
members have different values,var1.value
is3
,var2.value
is2
. On the other hand, their initializations are so much similar, therefore the result is surprising.Additional Context
Available solutions:
std::initializer_list<TYPE>
andTYPE, ...
signatures, because it's considered bad API design. Also find a way to fix bad API design of Cpp1 libraries (such asstd::vector
) in Cpp2 side too by extending them with new constructors.std::initializer_list<TYPE>
as the type of a list literal, and devote a notation such as[]
to create an instance of it in the same way that string types have their own string literals with notation""
.()
(direct initialization) or[]
(list initialization), and make them to fall back to each other in generic code.Also discussion #637 and issue #193 are related to this bug. Thanks.
The text was updated successfully, but these errors were encountered: