-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Casts broken in ROOT prompt #8304
Comments
Also note that the last example is missing a closing |
Hi @eguiraud and @Axel-Naumann, Actually, this is an instance of vexing parse. Specifically, in the context where The behavior seen in the second report is again due to vexing parse, and
In this case, the output
Also, as can be seen above, the diagnostic message provided by Clang has one extra Now, what can we do about this? IMHO, while I think that is the correct parsing, we should be probably issuing a warning. Any opinions on this? Cheers, |
Warn on redundant parentheses in declarators whose parsing might not match the user intent, e.g. ``` root [0] int i = 1; root [1] (bool)i (bool) true root [2] bool(i) ROOT_prompt_1:1:5: warning: redundant parentheses surrounding declarator [-Wredundant-parens] bool(i) ^~~ (bool) false ``` For more information see http://github.com/root-project/issues/8304. Closes issue root-project#8304.
Warn on redundant parentheses in declarators whose parsing might not match the user intent, e.g. ``` root [0] int i = 1; root [1] (bool)i (bool) true root [2] bool(i) ROOT_prompt_1:1:5: warning: redundant parentheses surrounding declarator [-Wredundant-parens] bool(i) ^~~ (bool) false ``` For more information see http://github.com/root-project/issues/8304. Closes issue root-project#8304.
Warn on redundant parentheses in declarators whose parsing might not match the user intent, e.g. ``` root [0] int i = 1; root [1] (bool)i (bool) true root [2] bool(i) ROOT_prompt_1:1:5: warning: redundant parentheses surrounding declarator [-Wredundant-parens] bool(i) ^~~ (bool) false ``` For more information see http://github.com/root-project/issues/8304. Closes issue root-project#8304.
Warn on redundant parentheses in declarators whose parsing might not match the user intent, e.g. ``` root [0] int i = 1; root [1] (bool)i (bool) true root [2] bool(i) ROOT_prompt_1:1:5: warning: redundant parentheses surrounding declarator [-Wredundant-parens] bool(i) ^~~ (bool) false ``` For more information see http://github.com/root-project/issues/8304. Closes issue #8304.
Warn on redundant parentheses in declarators whose parsing might not match the user intent, e.g. ``` root [0] int i = 1; root [1] (bool)i (bool) true root [2] bool(i) ROOT_prompt_1:1:5: warning: redundant parentheses surrounding declarator [-Wredundant-parens] bool(i) ^~~ (bool) false ``` For more information see http://github.com/root-project/issues/8304. Closes issue root-project#8304.
As @jalopezg-git mentioned, bool(foo) appears as a declaration (bool foo). The following simple C++ code also fails to compile with a re-declaration error and I think that should be the expected behavior. #include<iostream>
int main() {
int i = 54;
bool(i);
} |
My opinion is if the user employs C-style casts and not e.g. |
The challenge here is that the code does silenty the 'wrong' thing. The compiler and the case where shadowing is disabled, correctly fail with a good error. While the current prompt will do the wrong thing completely. On the other hand the issue is likely not severe as this only affect the prompt (where one would possibly cast to get a 'better' printout) and would not affect scripts. (I.e. despite being silent, the user might still notice). |
Exactly, it's not severe for many reasons, and it's not even wrong behavior given clings re-declaration feature. Indeed a warning in this case would be nice-to-have, but the issue claims "casts broken in ROOT prompt", which is not the case. |
Describe the bug
Weird/wrong results printed when converting different entities to
bool
:The text was updated successfully, but these errors were encountered: