Skip to content
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] Wrong error message for variable left uninitialized #1288

Open
JohelEGP opened this issue Sep 25, 2024 · 2 comments
Open

[BUG] Wrong error message for variable left uninitialized #1288

JohelEGP opened this issue Sep 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@JohelEGP
Copy link
Contributor

Title: Wrong error message for variable left uninitialized.

Description:

This change might have to do with commit 797569a.
There need to be regression tests for all of cppfront's diagnostics.

Minimal reproducer (https://cpp2.godbolt.org/z/MzqbWKzM9):

main: () = {
  x: int;
}
Commands:
cppfront main.cpp2
clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -Werror=unused-value -Werror=unused-parameter -Werror=unused-variable -I . main.cpp

Expected result: A diagnostic about x never being initialized.

Actual result and error:

Output:
main.cpp2...
main.cpp2(2,3): error: local variable x is used before it was initialized
  ==> program violates initialization safety guarantee - see previous errors
@JohelEGP JohelEGP added the bug Something isn't working label Sep 25, 2024
@JohelEGP
Copy link
Contributor Author

Also, what happened to cppfront's unused variable diagnostic?
I remember that being a thing, though I may be wrong.
See https://cpp2.godbolt.org/z/6n63hzzo3, which is rejected by the Cpp1 compiler via -Werror,-Wunused-variable.

@JohelEGP
Copy link
Contributor Author

JohelEGP commented Oct 2, 2024

Also, what happened to cppfront's unused variable diagnostic?

This check was added in 243d03d
-- #832 (comment)

Did I maybe undo it with #887?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant