-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Different behavior of CFE and the analyzer when constant depends on itself #59945
Comments
Summary: Analyzer detects self-referential constant |
cc @eernstg |
The language team decided that cyclic dependencies should be computed based on a simple syntactic criterion: If a non-local variable declaration D1 has an initializing expression e where the name that resolves to a declaration D2 occurs then D1 depends on D2. A compile-time error occurs if the dependency graph has a cycle. This means that a syntactically cyclic set of declarations will be reported as a compile-time error even in the case where some analysis can prove that no infinite loop will occur during initialization. The implementation was handled in #50383. There was no need to change the specification. We could try to introduce special rules about constant expressions because they have a control flow which is known at compile time (or link time, depending on the treatment of some constructors whose name includes So I'd say that the analyzer is right and the CFE should be adjusted such that all syntactic circularities are reported. I changed the labels accordingly. |
The following code produces an error in the analyzer but no issues in VM.
If to change the example to really invoke the constant then VM produces an error as well.
@eernstg @lrhn does in the first case the constant really depends on itself?
The text was updated successfully, but these errors were encountered: