-
Notifications
You must be signed in to change notification settings - Fork 260
[BUG] No type safety when comparing two incompatible variables #817
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
Comments
@MaxSagebaum Is this what you meant with #810 (comment)? |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, I was wrong.
|
So this is a related discussion: #623. |
Yes, I agree this is annoying. C and C++ For Cpp2, I briefly considered changing For Cpp2, and all C++ generally including both Cpp1 and Cpp2, I think the best solution is to encourage more use of C++20
This gives better diagnostics, by avoiding the Now all the compilers do a lot better -- all compilers still spit a LOT of diagnostics for this because they list all the possible
I do wish it was easier to find the original |
OK, I've found a solution that makes the original error message a lot better... I can stick a Now the code at top gets:
The original code at top was:
And with the commit I just pushed, this now gets these error messages:
Much better. Thanks @alexgb0 for pointing this out, and @JohelEGP for the discussion. (*) There are other examples, such as |
Kind of. But the list of the possible operators is a cpp1 problem. The solution of Herb the way to go I think. |
The solution with commit 6b48a72 adds more uses of |
Can you give an example that shows the problem, that we can track with a new issue? |
For starters (https://cpp2.godbolt.org/z/7r14PWh43):
That might not work so well, so here's another example (https://cpp2.godbolt.org/z/zfsjYfobe):
|
Describe the bug
No type safety when comparing two variables
To Reproduce
Steps to reproduce the behavior:
cppfront -p main.cpp2 && g++ main.cpp -std=c++23 -I/root/cppfront/include/ -o main
Some kind of error message saying you can't compare incompatible types
Additional context
I know it is a stupid problem, but I didn't pay attention and I have to admit that it took me some time to realize where was the problem.
The text was updated successfully, but these errors were encountered: