You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The initialization safety guarantee informs that the global variable is a local variable and that it needs to be initialized before the local variable in the function.
i : int;
main: () -> int = {
j : int;
j = 42;
i = 12;
}
Compile it with cppfront and we get an error:
cppfront % build/external/cppfront external/tests/global_variable.cpp2
external/tests/global_variable.cpp2...
global_variable.cpp2(5,5): error: local variable i must be initialized before j (local variables must be initialized in the order they are declared)
==> program violates initialization safety guarantee - see previous errors
Expected behavior: i is a global variable and (according to the error message) should not be considered in checking the order of initialization of the local variables.
The text was updated successfully, but these errors were encountered:
filipsajdak
changed the title
[BUG] Global variable treated as local variable
[BUG] Global variable treated as local variable by initialization safety guarantee rule
Oct 9, 2022
Uh oh!
There was an error while loading. Please reload this page.
The initialization safety guarantee informs that the global variable is a local variable and that it needs to be initialized before the local variable in the function.
Compile it with cppfront and we get an error:
Expected behavior:
i
is a global variable and (according to the error message) should not be considered in checking the order of initialization of the local variables.The text was updated successfully, but these errors were encountered: